These instructions were developed on a server with:
Virtuozzo VPS running Red Hat Enterprise 3, Plesk 7.5.4, and Apache 2.0.40.
However, these instructions have been used with other Plesk set-ups (please see comments at the end, and “gotchas” in the instructions for more details):
Fedora Core 4 & Plesk 8
Fedora Core 2 & Apache2 & Plesk
Virtuozzo VPS running CentOS 4.4, Plesk 8.0.1, and Apache 2.0.52.
These instructions are based on the following sources:
http://wiki.rubyonrails.com/rails/pages/HowtoInstallAndRunRubyOnRailsOnCpanel
http://soapboxconfessional.com/articles/2005/05/25/rails-on-plesk
http://wiki.rubyonrails.com/rails/pages/Ruby+and+Rails+on+Red+Hat+Enterprise+Linux
Many Plesk installations are quite minimal as you are not expected to be fooling around with the server much via commandline. So if the Gotchas don’t help you then please pay attention to the error messages and use the logs. Most things which won’t compile will be missing library files and/or -devel packages.
These instructions assume you are running as a superuser.
-
#Step(s) 0:
#MediaTemple
On Media Temple you may need to get the development kit installed and set up the root password. Also the server does not come with pico or Nano (text editors).
In /usr/local/src
wget <a href="http://www.nano-editor.org/dist/v1.2/nano-1.2.5.tar.gz">http://www.nano-editor.org/dist/v1.2/nano-1.2.5.tar.gz</a> cd nano-1.2.5 ./configure make make install
#Check for zlib
This shouldn’t be necessary for most most people so you can skip this step. However, it may be wise to make sure you have zlib installed before you continue. If you do not have zlib then you will get an error message “require__�? when you try to install rails in step 3.
The way I did it was to create a file called phpinfo.php in my httpdocs with the following:
*
<?php
// Show all information, defaults to INFO_ALL
// phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
*-
Gotchas
On my mediatemple AS (application server) there wasn’t even GCC installed. I had to go at get it done myself.
Here are the steps I took to get it done…(as root of course)
cd /usr/local/src
wget ftp://rpmfind.net/linux/redhat-archive/9/en/os/i386/RedHat/RPMS/gcc-3.2.2-5.i386.rpm
wget ftp://rpmfind.net/linux/redhat-archive/9/en/os/i386/RedHat/RPMS/cpp-3.2.2-5.i386.rpm
wget ftp://rpmfind.net/linux/redhat-archive/9/en/os/i386/RedHat/RPMS/glibc-devel-2.3.2-11.9.i386.rpm
wget ftp://rpmfind.net/linux/redhat-archive/7.2/en/os/i386/RedHat/RPMS/kernel-headers-2.4.7-10.i386.rpm
rpm -Uvh kernel-headers-2.4.7-10.i386.rpm
rpm -Uvh glibc-devel-2.3.2-11.9.i386.rpm
rpm -Uvh cpp-3.2.2-5.i386.rpm
rpm -Uvh gcc-3.2.2-5.i386.rpm
I got all of the RPMs from rpmfind.net – these should work on mediatemple since I’m assuming all their boxes use the same cpu/os
The additional rpm’s are dependencies needed by GCC.
-
#Step 1:
#Install Ruby
You need Ruby 1.8.2 or later to run rails. If your OS vendor supplies a packaged version for you, you can use that. Otherwise, you’ll need to download the latest source and compile it yourself.
You check the latest source version at http://ruby-lang.org/en/20020102.html) – as of 12/12/06, you probably want to use Ruby 1.8.5-p2, which fixes a couple denial of service bugs in 1.8.5 and lower.
cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5-p2.tar.gz
tar xvzf ruby-1.8.5-p2.tar.gz
cd ruby-1.8.5-p2
./configure
make
make install
-
#Step 2:
#Install Ruby Gems
Check Latest version and here:
http://rubyforge.org/frs/?group_id=126
http://rubyforge.org/projects/rubygems/
cd /usr/local/src
wget http://rubyforge.org/frs/download.php/5207/rubygems-0.9.0.tgz
tar xvzf rubygems-0.9.0.tgz
cd rubygems-0.9.0
ruby setup.rb
-
#Step 3:
#Install Rails
Once Gems are installed its a whirl to install Rails.
$ gem install rails
It will ask you whether it should install some dependencies;
say “y�? to all of them.
-
#Step 4:
#Install FastCGI
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.
-
Step 4.1:
Install the FCGI Development Kit
Check source version at http://fastcgi.com/dist/
This one is just like the Ruby installation:
cd /usr/local/src
wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -xvzf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure && make && make install
-
More Gotchas
When trying to make mod_fastcgi I ran into this problem:
Makefile:12: /usr/lib/httpd/build/special.mk: No such file or directory
make: *** No rule to make target `/usr/lib/httpd/build/special.mk'. Stop.
…Fixed it by doing an rpm install of httpd-devel (it didn’t affect any of the apache config files — site continued to work):
$ rpm -Uvh httpd-devel-2.0.46-11.ent.i386.rpm
the mod_fastcgi ‘make’ then complained about needing libtool. fixed that by installing the following:
$ rpm -Uvh automake-1.6.3-5.noarch.rpm
$ rpm -Uvh autoconf-2.57-3.noarch.rpm
$ rpm -Uvh libtool-1.4.3-6.i386.rpm
-
Step 4.2:
mod_fastcgi for Apache 2+
cd /usr/local/src
wget http://fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar -xvzf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
cp Makefile.AP2 Makefile
Edit Makefile (type: pico Makefile) and change:
top_dir = /usr/local/apache2
to
top_dir = /usr/lib/httpd
Save your changes (cntrl-x in pico) and then make & install:
make
make install
-
Step 4.3
Install Ruby-FCGI Bindings
gem install fcgi
-
Step 4.4
Install Ruby-MySQL Bindings
gem install mysql
If this fails try:
gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql
-
#Step 5
#Configure Apache
You now need to edit your Apache config file but this can be overwritten by plesk so we need to create a file called fastcgi.conf
-
Step 5.1
fastcgi.conf
fastcgi.conf needs to be created in /etc/httpd/conf.d/
pico /etc/httpd/conf.d/fastcgi.conf
Add these lines:
*
User apache
Group apache
LoadModule fastcgi_module modules/mod_fastcgi.so
FastCgiWrapper on
FastCgiConfig -idle-timeout 900
FastCgiIpcDir /tmp/fastcgi_ipc/
AddHandler fastcgi-script .fcgi .rb
*
Notes:
"conf.d/*") but we cannot (because Plesk overwrites httpd.conf) so putting them in fastcgi.conf is a quick fix. It should not matter that they will esentially appear twice.
LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so
chown -R apache.apache /tmp/fastcgi_ipc
chmod -R 755 /tmp/fastcgi_ipc
Or, of course, you could just chmod 777 the directory… :)
-
Step 5.2
Restart Apache
Before restarting apache make sure you haven’t done something stupid:
apachectl configtest
If everything is OK then restart:
apachectl -k graceful
Ruby on Rails should now be successfully installed.
-
#Step 6:
#Testing Your installation
Notice I said “should”. I firmly believe in checking things so…
-
Step 6.1
Install Test Application
You can test RoR out by creating a test application. Note, it will probably help if you do not do this as root (as I did). Try doing it as the user for the account you are installing your test application into. Hopefully, if you use the correct user, you won’t need to do Step 6.2.
cd ~USER
rails testapp
cd testapp/
script/generate controller test
cd ../httpdocs
ln -s ../testapp/public rails
Replace USER with the appropriate username ;)
-
Step 6.2
Check Ownership
The owner of the directories and symbolic link created should be USER:psacln so ls -a to find out what they are (ls -a). If they are not correct then:
cd ~USER
chown -R USER.psacln testapp
chmod -R 755 testapp
chown -Rh USER.psacln httpdocs/rails
chmod -R 755 httpdocs/rails
NB: You may need to set your /testapp/tmp/sessions/ folder permissions and /testapp/log/ files to give your webserver access.
-
Step 6.3
Create Test Pages
If you now naviagte to http://www.yourtestdomain.com/rails/ you should see a “Congratulations” page. However, this is just HTML, to ensure that your installation is working create some test pages:
cd ~USER
cd testapp/app/controllers
pico test_controller.rb
Change the text so that it reads
class TestController < ApplicationController
def hi
render :text => 'Hi world'
end
def hello
end
def index
render :text => 'Hi! This is the Index.'
end
end
And now for the cool bit
pico ../views/test/hello.rhtml
*
<html>
<head>
<title>Hello World
Hello from Rails!
The current time is <%= Time.now %>