I love Ubuntu. “Why not?”, you may ask. Well, the only reason is that I have worked almost exclusively with Ubuntu when deploying Rails applications.
Aside from the point that it’s easier and most tutorials on the internet involve Ubuntu deployment, at my current company, we only use Ubuntu on our staging and production server.
I always had the notion that deployment on other Linux distributions would be hard. It turns out, they may not be that different at all. Here’s the deployment recipe I’m using to deploy on CentOS 6.
yum -y groupinstall "Development Tools"
groupinstall "Development Tools" will install necessary tools to create a basic development environment. Next step would be to make sure we don’t miss out on some other tools.
yum -y install ntp zlib zlib-devel sqlite-devel httpd mysql-server mysql-devel curl-devel httpd-devel apr-devel apr-util-devel mlocate manlibxml2-devel libxslt-devel libffi-devel readline-devel gcc gcc-c++ make openssl-devel sqlite-devel /etc/init.d/ntpd stop ntpdate pool.ntp.org /etc/init.d/ntpd start chkconfig ntpd on
We are using ruby version 1.9.3 because Passenger 4.0 can’t work with 2.0.0 yet.
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p429.tar.gz tar zxf ruby-1.9.3-p429.tar.gz cd ruby-1.9.3-p429 ./configure make make install cd ext/openssl ruby extconf.rb make make install cd ../zlib ruby extconf.rb make make install cd ../readline ruby extconf.rb make make install cd gem update --system
If you are presented by this error:
It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.
A simple fix would be to install
curl -O http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/atomic-release-1.0-14.el6.art.noarch.rpm sudo rpm -Uvh atomic-release-1.0-14.el6.art.noarch.rpm sudo yum install libyaml-devel
And then reinstall Ruby.
Install Rails and Passenger
gem install rails passenger
Install the Passenger and Apache module
After installation, you will be presented by some text(see below) you need to add to your Apache config file, which can be found here,
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-4.0.5 PassengerDefaultRuby /usr/local/bin/ruby
You will also be presented by an Apache configuration file that you can modify and use for your virtual host
Virtual Host file
<VirtualHost *:80> ServerName www.yourhost.com # !!! Be sure to point DocumentRoot to 'public'! DocumentRoot /somewhere/public <Directory /somewhere/public> # This relaxes Apache security settings. AllowOverride all # MultiViews must be turned off. Options -MultiViews </Directory> </VirtualHost>
Now if everything goes well, you can restart Apache.
Visit your url and voila! A newly deployed Rails Application!
Visit the Passenger site for more Information about Deploying Rails with Passenger on Apache