Debian Etch - MySQL and RoR

Previously we secured, updated and personalised our Debian Etch install ready for some action (see Debian Etch page 1 and page 2) .

Now we can install MySQL and Ruby on Rails with subversion and Postfix support.


MySQL install

Let's start by installing MySQL:

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby -y

Password

MySQL installs with a blank password for the root user (don't confuse this 'root' user with your Slice root user - this is the MySQL user that has administration rights to the databases, not to your system).

Let's add a password:

mysqladmin -u root password YOURMYSQLPASSWORD

InnoDB

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:

skip-innodb

Ruby on Rails install

Now we'll install ruby from the apt repositories and then installing rubygems via source code:

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby -y

Symlink

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

Update

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.

Rubygems

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

Version

Once done, we can check the gem version with a:

gem -v
...
1.1.0

Excellent. Up to date.

Update

Whenever you need to update the installation just enter the following:

sudo gem update
sudo gem update --system

Rails

Now we can install rails with the command:

sudo gem install rails

The basic Ruby on Rails install is now finished. Let's extend the install with imagemagick and a quick ruby test as follows:

sudo aptitude install imagemagick librmagick-ruby1.8 librmagick-ruby-doc libfreetype6-dev xml-core -y

Testing

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 (if we don't do this now, other programmes will install exim and all sorts of unneeded email help). Once done we can install subversion so we can 'check-out' plugins and other goodies for 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.

That's it

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.

PickledOnion.

Article Comments:

Frederico Leonardo commented Wed Oct 03 10:28:06 UTC 2007:

I've been reading that the Debian Ruby package installs version 1.8.5. To get the latest Rails version (1.2.3) Ruby 1.8.6 is needed. Is there a way of getting the latest version without compiling from source? Thanks.

PickledOnion commented Wed Oct 03 10:33:27 UTC 2007:

Frederico,

Although the ruby version in Debian Etch is 1.8.5, Rails is installed via rubygems. Installing rubygems as shown in the article and then doing a: sudo gem install rails will install the latest version of rails (v1.2.3 at the moment).

Unless you compile from source or start adding unsupported repos to your sources.list I do not know of a way of getting ruby 1.8.6.

PickledOnion.

Frederico Leonardo commented Thu Oct 11 18:06:24 UTC 2007:

Thanks :-) As I've been testing different ways of having to rebuild my slice, I found out that Debian Lenny installs all the latest, including RubyGems. Is Lenny too unstable?

PickledOnion commented Thu Oct 11 21:07:25 UTC 2007:

Hi,

My main concern is the following from the Debian site regarding Lenny: Please note that security updates for testing distribution are not managed by the security team. Hence, testing does not get security updates in a timely manner.

So it depends what you after. A development Slice where you only test, etc may fine with Lenny but I personally would not recommend it for a production slice where it is exposed to the public.

I hope that helps.

PickledOnion.

Vivek Sharma commented Wed Nov 21 06:32:38 UTC 2007:

I kept hitting some big problems with the RMagick package install. The installer would complain that it couldn't find the Magick-config file.

libmagick6-dev seems to be out of the way. This seems to fix the issue:

sudo apt-get remove --purge librmagick-ruby-doc librmagick-ruby1.8 sudo apt-get install libmagick9-dev ruby1.8-dev

sudo gem install rmagick

Credit goes to Inlet Media for the solution: http://blog.inlet-media.de/rmagick-does-not-play-well-on-ubuntu

PickledOnion commented Wed Nov 21 10:17:54 UTC 2007:

Vivek,

Thanks for the link - I'll look into it as well and update the articles as needed.

Cheers,

PickledOnion.

Jonathan commented Sat Jan 12 01:52:54 UTC 2008:

I think mysql installs the exim email server if postfix isn't installed first.

i don't really know much about email servers, does exim do something different?

Romil Kulshreshtha commented Sun Jan 27 09:01:04 UTC 2008:

A number of components such as Perl are not found while installing MySQL with given command:

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby -y

Randy commented Mon May 12 22:55:53 UTC 2008:

I had problems getting RMagick installed on 8.0.4, even following the instructions on the previous link.

This worked for me.

https://bugs.launchpad.net/ubuntu/+source/librmagick-ruby/+bug/220811/comments/9

Sam commented Thu Jul 17 22:35:47 UTC 2008:

Hello, I'd like to know which webserver is most appropriate and light for a 256mb slice, also would you be able to squeeze in phpmyadmin and still be ok with all this? Plus would SQLite make a huge difference like the difference between a really fast box and a slow box?

Lukas Rieder commented Sun Jul 20 15:29:20 UTC 2008:

If you want to have Ruby 1.8.6 installed on your debian etch machine you can add the debian backports to your /etc/sources.list.

echo "deb http://www.backports.org/debian etch-backports main contrib non-free" >> /etc/apt/sources.list

Then you should get the keys for the backports so that apt trusts them: wget -O - http://backports.org/debian/archive.key | apt-key add -

And select the right version (ruby1.8.6) within aptitude.

Have a nice day,

Lukas

indiehead commented Thu Jul 31 14:27:08 UTC 2008:

thanks for that Lukas, modified the command to install 1.8.7 thru backports, brilliant work!

sudo aptitude -t etch-backports install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby -y

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)