25th
Install Rails with Phusion Passenger and MySQL on Debian 4.0 etch
Download a Debian etch netinst CD image and start to install.
During the installation process, you will see a Software selection screen. Uncheck the option to install the desktop environment, and check the option to install the web server. This will install Apache for you.
After installing the main system, we don’t need the CD image anymore, yet Debian likes to keep it available as a source for retreiving packages. You can remove the line in /etc/apt/sources.list that starts with “deb cdrom”.
After that, make sure you have the latest packages from Debian.
apt-get update
Install the essentials that we will need to build software from source, as well as SSH, sudo, and Subversion support.
aptitude install ssh gcc sudo build-essential make subversion -y
Install MySQL.
aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby -y
When Debian installed Apache automatically, it didn’t include the development headers, which Passenger requires.
apt-get install apache2-prefork-dev
Now, if you install Ruby using apt-get, it will install 1.8.5 which is not compatible with Phusion Passenger. So, we should install Ruby from source. Version 1.8.7 doesn’t work either, but 1.8.6 is just right. Passenger also requires openssl support, so we will include that in the configuration.
cd /usr/src wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p114.tar.gz tar xfz ruby-1.8.6-p114.tar.gz cd ruby-1.8.6-p114 ./configure --prefix=/usr/local --with-openssl-dir=/usr/lib make make install
The version of RubyGems that installs using apt-get is also incompatible, so we will build that from source as well.
cd /usr/src wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz tar xfz rubygems-1.3.1.tgz cd rubygems-1.3.1 ruby setup.rb
Now use RubyGems to install Rails, the MySQL gem, and Phusion Passenger. The following command could take awhile.
gem install rails mysql passenger
That’s all the software we need to install. Now we just have some configurations, starting with Passenger.
passenger-install-apache2-module
The instructions will tell you to edit your Apache configuration file (located at /etc/apache2/httpd.conf) and add the following lines:
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.6 PassengerRuby /usr/local/bin/ruby
You may also want to change the root password for MySQL.
mysqladmin -u root password NEWPASSWORD
With that, all that is left is to restart Apache for the changes to take effect.
apache2ctl -k restart