Rails on Plesk
Rails on Plesk
Hi, folks! It seems a few of y’all might be interested in hearing how to get Ruby on Rails set up on a Plesk server. I did it last month, and it wasn’t terribly difficult, so I thought I’d write a quick guide to the process.
But first, two quick caveats:
1. I did this on a server running PSA 7.5.2 on Red Hat Enterprise Linux 3. The process is probably the same for other Red Hat/Fedora versions, but it might be a bit different on other distros or FreeBSD.
2. I’m assuming that you are comfortable with compiling and installing software from source. If that’s not something you’re familiar with, there is great little howto here that can help you get started.
Step one: Install Ruby
You need Ruby 1.8.2 or later to run rails. If your OS vendor supplies a packaged version for you, use that. Otherwise, you’ll need to download the latest source from ruby-lang.org) and compile it yourself. I didn’t do anything unusual on my ruby installation; just ./configure, make, and make install.
Step two: Install the FCGI Development Kit
There are three pieces of FastCGI software that must be installed on your server to run rails applications: The FastCGI development kit, the mod_fastcgi Apache module, and the Ruby FastCGI bindings. We’ll do the first one now. You can download it from fastcgi.com. This one is just like the Ruby installation: ./configure, make, and make install.
Step three: Install mod_fastcgi
Mod_fastcgi doesn’t have an automated installation process, so this one is a bit more complicated:
1. Download the source code from fastcgi.com and extract it into /usr/local/src.
2. cd mod_fastcgi-2.4.2
3. cp Makefile.AP2 Makefile (this is required since we’re using apache 2.x, not 1.3)
4. Open Makefile in your favorite editor. Change the line that says top_dir = /usr/local/apache2 to top_dir = /usr/lib/httpd
5. make
6. make install
Step four: Install RubyGems
RubyGems is the ruby package manager (If you’re familiar with Perl’s CPAN module, RubyGems is basically the same idea). It can be downloaded from rubyforge.
RubyGems doesn’t use GNU autoconf or automake, so the installation command is a bit different: instead of ./configure, make, and make install, you just do ruby setup.rb all.
Step five: Install Rails, Ruby-FCGI and Ruby-MySQL
Once you have Ruby and RubyGems installed, getting rails is easy: just gem install rails. It will ask you whether it should install some dependencies; say “y” to all of them. When that’s done, gem install fcgi to get the Ruby FastCGI bindings, and gem install mysql to get the Ruby MySQL bindings.
Step six: Configure Apache
To make Apache use the FastCGI module, copy this into /etc/httpd/conf.d/fastcgi.conf:
LoadModule fastcgi_module modules/mod_fastcgi.so
FastCgiWrapper on
FastCgiConfig -idle-timeout 900
Restart apache, and you’re done!
Wait—two more quick notes!
1. This guide only covers server-wide configuration; there are a few tricks to setting up individual rails apps in Plesk as well. If an article about setting up an individual rails app would be helpful to you, drop me a line and I’ll see what I can do. (Update: The follow-up article is available here)
2. This guide is only based on my own experience. If you use it, and find ways that it could be better or more complete, leave a response, and by all means, I’ll do my best to fix it.