Ruby on Rails on a CentOS Virtuozzo VPS

By Scott on December 29th, 2006 @ 11:23 PM

Tags: , , , , ,
Posted in: Random Thoughtiness, Ruby
Comments: 0

I've done this at least a dozen times in VMware, OpenVZ, and Virtuozzo virtual servers. Every time I do it I start from scratch. It's silly. This time I'm writing down the steps so I don't forget.

Getting Started

Let's start with a Virtuozzo powered VPS running a clean installation of CentOS 4.4. We begin by removing a few things that we just don't need right now.

  • Fetchmail
  • SWSoft's Apache build
  • SWSoft's Sendmail build
  • The Pop3 server that we don't need

Remove what gets in the way

rpm -e fetchmail hspc-wwwroot
rpm -qa | grep httpd | xargs rpm -e
rpm -qa | grep sendmail | xargs rpm -e
rpm -qa|grep ^apr|xargs rpm -e
rpm -e popa3d
service xinetd restart

Install yum

In the virtual server I am on right now, yum is not installed. Odd. Let's install it:

rpm -i http://mirror.centos.org/centos/4.4/os/i386/CentOS/RPMS/yum-2.4.3-1.c4.noarch.rpm \
       http://mirror.centos.org/centos/4.4/os/i386/CentOS/RPMS/python-elementtree-1.2.6-4.2.1.i386.rpm \
       http://mirror.centos.org/centos/4.4/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.i386.rpm \
       http://mirror.centos.org/centos/4.4/os/i386/CentOS/RPMS/sqlite-3.3.3-1.2.i386.rpm \
       http://mirror.centos.org/centos/4.4/os/i386/CentOS/RPMS/sqlite-devel-3.3.3-1.2.i386.rpm \
       http://mirror.centos.org/centos/4.4/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm

The CentOS-4 Testing repository

Now we want to add the c4-testing yum repository so we will install the latest Ruby rpm's. Or we can install from sources, but no point in doing that right now since c4-testing has Ruby 1.8.5.

cat << EOF > /etc/yum.repos.d/CentOS-Testing.repo
[c4-testing]
name=CentOS-4 Testing
baseurl=http://dev.centos.org/centos/\$releasever/testing/\$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
EOF
yum -y update

Install Ruby, and Rails

As mentioned previously, you can install Ruby from sources or use the RPM provided in the CentOS repository. I use the CentOS built Ruby simply because it's already at the latest version (1.8.5 at this time) and it saves a little time.

Ruby

yum install -y ruby ruby-libs ruby-devel ruby-rdoc ruby-irb ruby-ri

Ruby Gems

wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
tar zxf rubygems-0.9.0.tgz
cd rubygems-0.9.0
ruby setup.rb

Rails, Mongrel, and Sqlite3-ruby

Rails, mongrel, and sqlite3-ruby:

gem install -y rails
gem install -y mongrel
gem install -y sqlite3-ruby

Apache and Subversion

And now we get to the tougher stuff. We need subversion if we plan to freeze_edge, which I always do during development. I also like to use Trac. We wont cover the installation of Trac today, but we'll make sure our environment is Trac friendly. More on that another time perhaps.

So let's get prepared for Subversion. We'll need the following items installed before we can build it the way we need it:

apr

Starting with apr and apr-util, we need to download, configure, build, and install from sources:

wget http://www.ip97.com/apache.org/apr/apr-1.2.8.tar.bz2
bzip2 -dc apr-1.2.8.tar.bz2 | tar xf -
cd apr-1.2.8
./configure && make && make install

apr-util

wget http://www.ip97.com/apache.org/apr/apr-util-1.2.8.tar.bz2
bzip2 -dc apr-util-1.2.8.tar.bz2 | tar xf -
cd apr-util-1.2.8
./configure --with-berkeley-db --with-apr=/usr/local/apr/bin/apr-1-config && make && make install

Apache Web Server

wget http://apache.downlod.in/httpd/httpd-2.2.3.tar.bz2
bzip2 -dc httpd-2.2.3.tar.bz2 | tar xf -
cd httpd-2.2.3
./configure -C \
            --prefix=/usr/local \
            --with-apr=/usr/local/apr/bin/apr-1-config \
            --with-apr-util=/usr/local/apr/bin/apu-1-config \
            --datadir=/var/www/home \
            --sysconfdir=/etc/httpd/conf \
            --enable-dav \
            --enable-suexec --with-suexec \
            --with-suexec-caller=apache \
            --with-suexec-docroot=/var/www \
            --with-suexec-logfile=/var/log/httpd/suexec.log \
            --with-suexec-bin=%{_sbindir}/suexec \
            --with-suexec-uidmin=500 --with-suexec-gidmin=500 \
            --with-devrandom \
            --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache \
            --enable-ssl --with-ssl \
            --enable-deflate --enable-cgid \
            --enable-proxy --enable-proxy-connect \
            --enable-proxy-http --enable-proxy-ftp \
            --enable-proxy-balance && make && make install

Neon

wget http://www.webdav.org/neon/neon-0.25.5.tar.gz
tar zxf neon-0.25.5.tar.gz
cd neon-0.25.5
./configure --with-ssl=openssl && make && make install

SWIG

wget http://prdownloads.sourceforge.net/swig/swig-1.3.31.tar.gz
tar zxf swig-1.3.31.tar.gz
cd swig-1.3.31
./configure && make && make install

Subversion

wget http://subversion.tigris.org/downloads/subversion-1.4.2.tar.bz2
bzip2 -dc subversion-1.4.2.tar.bz2 | tar xf -
cd subversion-1.4.2
./configure --with-apxs=/usr/local/bin/apxs \
            --with-swig=/usr/local \
            --with-ssl \
            --with-neon=/usr/local \
            --with-apr=/usr/local/apr/bin \
            --with-apr-util=/usr/local/apr && make && make install

Good to go

At this point we're good to go. I usually install Vim7 right about now because I prefer to do all my coding in vi. CentOS 4 only has Vim6; Vim7 has newer rhtml and rb syntax files. Adding PostgreSQL or MySQL will complete your stack for a production environment. Sqlite3 is great for getting the ball rolling. Now it's time to be a Really Useful Engine and get working on your shiny new Rails app.

Good luck!

Comments

None yet.

Post a comment

Boiler Plate theme for Mephisto Copyright 2006 by Scott Deming.