# Notes for setting up Ruby on Rails on Plesk 7.5.4 on a Centos 3 (aka Redhat Enterprise 3 / RHEL3) machine. # Chris James, Systems Developer, Made Media (http://www.mademedia.co.uk/) # Wed 26 April 2006 # create a working directory. mkdir /usr/src/ruby cd /usr/src/ruby # install zlib - I had plenty of problems with zlib issues so compiled it from source. wget http://www.zlib.net/zlib-1.2.3.tar.gz tar -xzvf zlib-1.2.3.tar.gz cd zlib-1.2.3 mkdir working ./configure --prefix=./working make && make install # install ruby, using our compiled zlib cd /usr/src/ruby wget ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gz tar -xvzf ruby-1.8.4.tar.gz cd ruby-1.8.4 ./configure --prefix=/usr --with-zlib-dir=../zlib-1.2.3/working --with-static-linked-ext --enable-static make && make install # install gems cd /usr/src/ruby wget rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz tar -xvzf rubygems-0.8.11.tgz cd rubygems-0.8.11 /usr/bin/ruby setup.rb all # install rails cd /usr/src/ruby gem install rails --include-dependencies # install fastcgi cd /usr/src/ruby wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz tar -xzvf fcgi-2.4.0.tar.gz cd fcgi-2.4.0 ./configure --prefix=/usr make && make install # install fcgi for ruby - excluding rdoc as threw up errors. gem install fcgi --no-rdoc # install mod_fcgid - note required manual edit of file cd /usr/src/ruby yum install httpd-devel yum install libtool wget http://fastcgi.coremail.cn/mod_fcgid.1.09.tar.gz tar -xzvf mod_fcgid.1.09.tar.gz cd mod_fcgid.1.09 vim Makefile # change top_dir to /usr/lib/httpd make make install # tell apache to load mod_fcgid cat > /etc/httpd/conf.d/fcgid.conf < AddHandler fcgid-script .fcgi SocketPath /tmp/fcigdsock IdleTimeout 60 ProcessLifeTime 6000 MaxProcessCount 64 DefaultMaxClassProcessCount 8 DefaultMinClassProcessCount 2 IPCConnectTimeout 30 IPCCommTimeout 20 DefaultInitEnv RAILS_ENV production endoffile # install mysql ruby bindings yum install mysql-devel # note copy and paste all following three lines at once... gem install mysql -- \ --with-mysql-include=/usr/include/mysql \ --with-mysql-lib=/usr/lib/mysql # nb. (select option 2 or the latest mysql for ruby - !!not win32!!) # restart the webserver. hopefully it won't crash out - you may wish to check first with apachectl... apachectl configtest apachectl -k graceful /etc/init.d/httpd restart # now create a new test domain in plesk for testing your install # this is up to you - I used the Plesk web interface with a ftp username of chirs # domain name of railstest.mmnet.co.uk at /var/www/vhosts/railstest.mmnet.co.uk # note /var/www/vhosts is later version of Plesk only. Earlier ones had /home/httpd/vhosts. # Create a new rails app cd /var/www/vhosts/railstest.mmnet.co.uk rails rails chown -R chris:psacln rails # If you want to use a prepackages rails application, you can install your app in it now. # This is down to you (perhaps untar it or ftp it up!) # remember to follow the install instructions for the app. # You **don't** need to do this just to test rails is working. # now you need to make a slight change to .htaccess file in rails, manually cd /var/www/vhosts/railstest.mmnet.co.uk/ vim rails/public/.htaccess # (around about line 2) change AddHandler fastcgi-script .fcgi to ... # AddHandler fcgid-script .fcgi # (around about line 32) change RewriteRule ^(.*)$ dispatch.cgi [QSA,L] # to RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] # Now link rails in to the httpdocs directory cd /var/www/vhosts/railstest.mmnet.co.uk/ ln -s ../rails/public httpdocs/rails chown -R chris:psacln httpdocs/rails # now you should be able to go to http://railstest.mmnet.co.uk/rails (ie you're own domain) # and use your new rails install. ("Welcome aboard, You're riding the Rails!") # once you have your app going (note it won't work for just the welcome screen), to check # your app is using fcgid, after visiting your site, on the command line you can run ps aux | grep [d]ispatch.fcgi # it should return a line like this: # chris 29300 1.0 4.5 27312 23544 ? S 12:10 0:01 ruby dispatch.fcgi # that's it! :) # I would like to give credit to the other tutorials I followed, but I used that many that I've lost # track - so thanks to everyone who has made their install experience available on line.