General
Install Ubuntu 9.1 server using the Bare Server option
The first thing I like to do is add my account to the /etc/sudoers file. This just guarantees that I can always use sudo, even if I mistakenly mess up my group assignment.
sudo visudo
# /etc/sudoers root ALL=(ALL) ALL user ALL=(ALL) ALL
user should be replaced with the account you use to administer the box. I like to do this because one time I messed up my group assignment on the only account that was able to admin the box.
alias sudo='sudo -E'
The reason we have that alias nonsense in there is because Ubuntu compiles the sudo command with the –with-secure-path option. We want to pass our current path into the command. The alias command is explained here. I’m sure there are some security vulnerabilities with muti-user systems doing it this way, but I’m the only guy so no need to figure it out right now.
Next, update the apt-get configuration and then upgrade to make sure the latest packages are installed.
sudo apt-get update sudo apt-get upgrade -y
Configure the server for static IP address.
SSH
Ruby
As I write this, the latest version of Ruby for apt-get is 1.8.7 patchlevel 174.
sudo apt-get install build-essential libssl-dev libreadline-dev rake -y sudo apt-get install ruby rdoc ri rubygems libopenssl-ruby ruby-dev -y
ln -s /var/lib/gems/1.8 /var/lib/gems/current
Now, source the file you just created. Sourcing a file uses the contents of the file as if you typed them at the command prompt. You just type a period followed by a space and then the filename.
. /etc/profile.d/gems.sh
You will notice that we did not install Rails. This is intentional. We will use
rake rails:freeze:gems
to freeze a known version of rails into our applications.
MySQL
sudo apt-get install mysql-server libmysqlclient-dev sudo gem install mysql
Apache
We will install Apache2 as well as Passenger (mod_rails or mod_rack).
sudo apt-get install apache2 libapr1-dev apache2-prefork-dev -y sudo gem install passenger
sudo /var/lib/gems/current/bin/passenger-install-apache2-module
After you run this, you will see instructions to add some lines to your Apache configuration file. Mine looked like this:
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.8 PassengerRuby /usr/bin/ruby1.8 LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.8 PassengerRuby /usr/bin/ruby1.8
Just copy this to it’s own file in the conf.d directory of apache2.
sudo vi /etc/apache2/conf.d/passenger.conf