After 2 days of off and on server admin, I’ve finally got a production server that can take Capistrano deployments without sacrificing the Plesk GUI!
Here are some of the highlights - most of the steps I used can be found in Time for a Grown-Up Server, so this is more of a list of gotchas to do with a Plesk setup. I’m sure I’m missing a thing or two here and there, so contact me if you’re stuck and I’ll either fill in the blanks or fix my typos. :)
Installing Apache 2.2
Capistrano’s cool by itself, but if I’m messing around with server crap, I want a Mongrel cluster at the same time. While Plesk 8.1 supports Ruby on Rails via FastCGI, Capistrano seems to work best with Mongrel, and more importantly, that’s how I’ve got another server configured, so I’d rather have a smaller set of problems to troubleshoot between the boxes.
Unfortunately, running a cluster requires mod_proxy_balancer on Apache, which isn’t available until Apache 2.2. Plesk comes with Apache 2.0. Urgh.
Upgrading requires a few steps. I used Bryan Thompson’s guide to get Apache in, but it turned out I needed to compile it with –enable-openssl. Once that was in, I had to figure out how to handle the server config. Plesk likes to overwrite /etc/httpd/conf/httpd.conf a lot, and it keeps its virtual server config info (with other files) in /etc/httpd/conf.d. I didn’t care much about the non-virtual stuff - I can set that up myself, so I kept httpd.conf in its new /usr/local/apache2/conf directory and added an Include /etc/httpd/conf.d/zz010_psa_httpd.conf to keep the one file I wanted in play. I also had to include mod_suexec to keep everything happy.
Mongrel and Capistrano
Using the ultimate Time for a Grown-Up Server guide, I was able to get Mongrel and Capistrano working. The catch was getting Plesk to be happy with it.
Your mileage may vary, but my Plesk-managed websites were located at /var/www/vhosts/[site name]/httpdocs. I wanted the document root to be [app base]/current/public, so I switched it over with a symlink - I added a directory at /var/www/vhosts/[site name]/website and made that my base directory for Capistrano. Then I deleted (OK, renamed) httpdocs, and once I ran cap setup to get the rest of the structure in place, I did an ln -s /var/www/vhosts/[site name]/website/current /var/www/vhosts/[site name]/httpdocs to line everything up.
That gave me a 403 error, because Plesk was set up to not follow symbolic links. Chowning and chgrp’ing the new httpdocs probably fixed that.
Finally, it’s good to test a reboot to make sure everything sticks. Sure enough, when I tried to access my site I got a 503 error. The Mongrel processes hadn’t started. Thankfully The Google had my back and this post pointed a possible problem (boot path issues), but the fix didn’t work for me - at first. Since I didn’t have console access, I redirected the outputs of the commands in /etc/init.d/mongrel_cluster and it turned out I was running a different version of ruby in /usr/bin that didn’t have rubygems installed. Updating that version did the trick.
So here I am - now I can develop wherever I want, check in my code, and deploy to production without ever touching the live web directory, but I can still use Plesk to manage the occasional little server thing that I don’t want to bother remembering, though granted, the more tasks like this that I do, the less I need Plesk for.
Technorati Tags: Plesk, Capistrano, Mongrel, Apache, Rails
Andrew Skegg | 04-Feb-07 at 8:04 pm | Permalink
I am so glad you have blazed a trail here - I have been wrestling with this configuration for a week now (mostly with the issues you describe). This should put me on the right path. I will post back here to let you know how I went.
Jason | 04-Feb-07 at 10:29 pm | Permalink
Cool. Let me know how it goes! I’ve been deploying every day or so with no major issues (except for the part where users get logged out every time…), and it’s awesome. I’m changing all my other apps to use something like this.
Ben | 07-Feb-07 at 3:26 pm | Permalink
Thanks for posting this. This is probably a silly question, but after installing Apache 2.2 how do I setup the server to use Apache 2.2 instead of Apache 2? That is, what do I need to change to make sure that when the server reboots or Plesk restarts Apache that 2.2 is used? Currently on my setup Apache 2.0 starts. I tried setting a symbolic link like so:
ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apachectl
chmod +x /usr/sbin/apachectl
Which works in terms of being able to start and stop Apache 2.2 with /usr/sbin/apachectl. But when I reboot the server, Apache 2.0 is started. Any ideas what I’m missing?
Thanks!
Jason | 07-Feb-07 at 4:18 pm | Permalink
OK, I’m forgetting more and more as time goes on, but that’s why it’s being written down, right?
I believe I linked 2.2 to the old 2.0 location, so in my case /etc/httpd/build got pointed to /usr/local/apache2/build and /etc/httpd/modules went to /usr/local/apache2/modules via ln -s
I wanted to keep the base Apache install in (roughly) the same location via the links just in case Plesk had any other assumptions about what goes where.
Give it a try and see if that helps!
doug | 31-Jul-07 at 2:24 pm | Permalink
Hey Jason,
I’m trying to do the same thing as you. I have Apache 2.2.4 compiled and installed, however when I include the zz file, it complains about mod_suexec being “garbled”.
Is it possible for you to go into a bit more detail the final steps you did such as (chowning/chgrping directories, handling suexec, apache 2.2.4 working with the /var/www/vhosts/* directory structure etc..)