We've already covered how to install MySQL on Debian Lenny, but now we need to prepare our Rails or PHP installations to make use of it.
In this article we will look at what other packages are needed for MySQL to integrate with Ruby on Rails and with a standard PHP install.
MySQL and Ruby on Rails
Assuming that you have already followed the Debian Lenny - Ruby on Rails Installation, we only have one package left to install (the MySQL Ruby Gem.)
Installing the mysql ruby gem is easy, simply run:
sudo gem install mysql
That's it! Now your rails application should be ready to use the mysql database adapter. Let's conduct a quick test using the 'irb' console to see if all is well:
irb #irb(main):001:0> require 'rubygems' => true #irb(main):002:0> require 'mysql' => true
Looks good! We were able to load the mysql gem just fine.
MySQL and PHP
If you installed Apache and PHP using the Debian Lenny - Apache and PHP article, you will already have the PHP MySQL module installed (which is 'php5-mysql').
This simple process also installs the PHP 'mysqli' (MySQL improved extension) module. This allows for much more powerful MySQL usage within PHP - please see the PHP mysqli page for more details.
A standard phpinfo page shows the following information for the mysql and mysqli modules:
As you can see, installation is very easy.
Installing MySQL via the 'aptitude' package manager is very simple and ensures you have any security updates if and when they are released.
Installing the necessary packages for MySQL to integrate with Ruby on Rails and PHP is a suitably easy process — allowing you to concentrate on the site design rather than messing with the installation itself.