As such, we can now install MySQL and Ruby on Rails with subversion and Postfix support.
Let's go ahead and install MySQL:
sudo aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby1.8 -y
During the installation of MySQL, you will be presented with this screen:
Setting the MySQL Root password is a recommended step in setting up your Slice. However, it is, of course, up to you.
Should you decide that protecting your production database is a good idea, then simply enter your chosen password as directed.
Note: The install will not ask for a repetition of the password so make sure you get it right when you enter the password!
If you are not going to use InnoDB with your MySQL databases, then it is a good idea to turn it off right at the start. It uses a lot of memory and, if not going to be used, this is wasted memory.
Open the main MySQL config file:
sudo nano /etc/mysql/my.cnf
Search my.cnf for the heading:
# * InnoDB
Then, to turn off InnoDB, simply uncomment (remove the #) on this line:
Ruby on Rails install
Now we'll install ruby from the apt repositories and then install rubygems:
sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby -y
We need to create some symlinks from the install to locations every programme would look. Each line below is a separate command:
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
Once done, we can have a look at the Ruby version:
ruby -v ... ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
Excellent. An up to date version.
Now we can install rubygems.
This articles has been updated to use the latest (at the time of writing) version of rubygems which is v1.2.0.
This version of rubygems has finally fixed the memory issues seen on smaller Slices.
You can now install, update and administer all your rubygems from within a 256Slice with no issues.
We are not going to use the package manager for this as the pre-package version of rubygems is 0.9.4 and, at the time of writing, the latest working version is 1.2.0.
Although you can update rubygems to the latest version from the command line, it is actually quicker and easier to install from source. This is especially true for smaller (256) Slices as the older version of rubygems had a horrendous memory issue when updating.
In fact, the previous version of this article did install via the package manager which was fine until the major updates to rubygems was released: Thanks to Janne, bovn, abenamer and Joel for the comments on workarounds, etc until it could be updated.
Anyway, let's go ahead and download the source code into our sources directory. If you haven't got a sources directory, you can simply create one:
mkdir ~/sources cd ~/sources ... wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
Then unpack it and move into the newly created folder:
tar xzvf rubygems-1.2.0.tgz cd rubygems-1.2.0
Now we can go through the simple process of compiling it and creating a symlink:
sudo ruby setup.rb ... sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
Once done, we can check the gem version with a:
gem -v ... 1.2.0
Excellent. Up to date.
Whenever you need to update the installation just enter the following:
sudo gem update sudo gem update --system
Now we can install rails with the command:
sudo gem install rails
The basic Ruby on Rails install is now finished.
If you want to use Ruby and ImageMagick, we can extend the install as follows:
sudo aptitude install imagemagick librmagick-ruby1.8 librmagick-ruby-doc libfreetype6-dev xml-core -y
Now we can do a test to see if the install works (thanks to brainspl.at for this idea).
irb #irb(main):001:0> require 'RMagick' #=> true #irb(main):002:0> require 'mysql' #=> true #irb(main):003:0> exit
Obviously, if the output does not return 'true' for each 'require' command, then something has gone wrong. If the result is correct and returns 'true' then we have a working ruby install.
Postfix and subversion
Finally, we need to install postfix and subversion so we can 'check-out' plugins and send mail from our Rails applications:
sudo aptitude install postfix subversion -y
Answer the postfix questions as you see fit but the defaults usually suffice for our purposes as we are only using it to send emails and not for receiving mail.
You now have a MySQL, Ruby on Rails and postfix/subversion stack setup and ready to roll.
Now you are ready to install the server of your choice whether that be Litespeed, Nginx or Apache.