This is a simple guide for running Ruby on Rails on Ubuntu 10.04 LTS using passenger for production environment. Everything was version specific and may be changed later on, just make sure that each package is compatible with each other.

Packages used
Ubuntu 10.04 Server
Ruby 1.8
Rails 2.1
rubygems 1.3.4
passenger 3.0.1
Apache2

1) Download and install a server version of Ubuntu, the advantage of using this is for you to avoid other installation such as the LAMP (Linux, Apache, MySQL, PHP) package which comes as an option upon installation of the said OS. Make sure that you install this part.

2) After installation, log in using the username and password that you have entered earlier during installation. From there, enter the following:

sudo apt-get update

3) After updating, install the other packages by typing:

sudo apt-get install ruby ruby1.8-dev irb rdoc build-essential mysql-client libmysql-ruby libmysqlclient15-dev

4) Next, install rubygems via downloading it, this is the most recommended way of doing this:
(NOTE: do not use, apt-get with this one)

wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
tar xvzf rubygems-1.3.4.tgz
cd rubygems-1.3.4.tgz
sudo ruby setup.rb

after this you may now try typing

gem -v

This should return this:

1.3.4

if this return error, simply link the file like this:

sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem

5) Install all necessary gems, but don't forget rails gem, so:

gem install rails -v 2.1

Do the same with mysql and passenger gems.

6) Next is to install passenger

sudo passenger-install-apache2-module

and then restart apache upon installation

sudo /etc/init.d/apache2 restart

7) Edit the apache configuration file (/etc/apache2/apache2.conf)

Add the following lines:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.1/ext/apache2/mod_passenger.so
PassengerRoot /usr/lin/ruby/gems/1.8/passenger-3.0.1
PassengerRuby /usr/bin/ruby1.8

8) Create another file for sites-available by typing:

sudo vi /etc/apache2/sites-available/[name_of_app]

Add the following to the said file:

<VirtuaHost *>
 ServerName [name_of_app]
 DocumentRoot /var/www/[name_of_app]
 RailsEnv production
 RailsBaseURI /[name_of_app]
</VirtualHost>

9) Type:

sudo a2dissite default
 sudo a2ensite [name_of_app]

Then reload apache2

sudo /etc/init.d/apache2 reload

10) Link your app to /var/www

sudo ln -s [app_location] /var/www/[name_of_app]


Also edit your environment.rb to Production environment and prepare your database.

No comments :

Post a Comment