Ruby - CentOS 5 - Virtualmin 3.49

Hi

I’m trying to follow this guide on setting up Ruby. http://www.virtualmin.com/documentation/id,ruby_on_rails_and_virtualmin/

I’ve installed all the required packages.

I can install without setting up database. If I choose to use the mysql database for the virtual server, the install errors out.

[code:1]
Now installing Ruby on Rails version 1.2.5 …

Rails MySQL driver install failed :
Select which gem to install for your platform (i386-linux)

  1. mysql 2.7.3 (mswin32)
  2. mysql 2.7.1 (mswin32)
  3. mysql 2.7 (ruby)
  4. mysql 2.6 (ruby)
  5. Skip this gem
  6. Cancel installation
    > 3
    Building native extensions. This could take a while…
    ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql --include-dependencies
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… yes
checking for mysql_query() in -lmysqlclient… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby
–with-mysql-config
–without-mysql-config
–with-mysql-dir
–without-mysql-dir
–with-mysql-include
–without-mysql-include=${mysql-dir}/include
–with-mysql-lib
–without-mysql-lib=${mysql-dir}/lib
–with-mysqlclientlib
–without-mysqlclientlib
–with-mlib
–without-mlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-zlib
–without-zlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-socketlib
–without-socketlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-nsllib
–without-nsllib
–with-mysqlclientlib
–without-mysqlclientlib

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

… failed! See the error message above for the reason why.
[/code:1]

Anybody using Ruby with Virtualmin 3.49 and mysql?

There is an oddity with the MySQL shared libraries on CentOS - they are not in a directory that Ruby looks in.

The fix is to login as root via SSH and install manually with the command :

gem install mysql – --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql

The go back into Virtualmin and re-try the Rails install.