New version of rails, means it’s time again for another article on setting up a production server to run it.

Like the previous articles on this topic, this is intended for for other developers then for clients, but clients can read along as well.

The prerequisites

Install some prerequisites to make the prcess smoother.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 mysql-server git-core ruby1.8 build-essential libssl-dev ruby rdoc irb libopenssl-ruby imagemagick libmagickcore-dev libmagickwand-dev  libmysqlclient15-dev apache2-prefork-dev libapr1-dev postfix libaprutil1-dev libcurl4-openssl-dev libxslt-dev libreadline6 libreadline6-dev

Notice, that unlike my previous articles, I am installing mysql here. This is because of the large number of emails I got stating that thy prefer to run MySQL on the web host. This is fine, and is all personal preference on smaller sites. Lager sites will need a separate database server. Notice ruby 1.8 being installed. You won’t actually use it but it helps avoid some “dependency hell”.

The following will build a recent version of libyaml. Your distribution may have a current version, I just find this to be safer.

wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar -xzvf yaml-0.1.4.tar.gz
cd  yaml-0.1.4
./configure --prefix=/usr/local
make
sudo make install

Build Ruby

Now we are going to build ruby. It’s pretty straight forward. Again your distrobution may have recent ruby versions but I prefer to build, test, and run on the same patch level

cd ~
mkdir ruby_src
cd ruby_src
wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
tar -xzvf ruby-2.0.0-p195.tar.gz
cd ruby-2.0.0-p195
./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/libnou
make
sudo make install

Now Ruby Gems

Another straight forward build. Do not use your distribution version of RubyGems Always use Rubygems from source so that it can update it’s self and the system without conflicts.

cd ~
wget http://production.cf.rubygems.org/rubygems/rubygems-2.1.7.tgz
tar -xzvf rubygems-2.1.7.tgz
cd rubygems-2.1.7/
sudo ruby setup.rb

Final Cleanup

In the end we just need to install passenger and bundler and were ready to go.

sudo gem install passenger --no-ri --no-rdoc
sudo passenger-install-apache2-module

Don’t forget to add the Configuration to apache.

sudo gem install bundler

Coteyr.net Programming LLC. is about one thing. Getting your project done the way you like it. Using Agile development and management techniques, we are able to get even the most complex projects done in a short time frame and on a modest budget.

Feel free to contact me via any of the methods below. My normal hours are 10am to 10pm Eastern Standard Time. In case of emergency I am available 24/7.

Email: coteyr@coteyr.net
Phone: (813) 421-4338
GTalk: coteyr@coteyr.net
Skype: coteyr
Guru: Profile