Ruby on Rails for RHEL 5

Here is the quick and dirty Ruby on Rails setup for Redhat Enterprise Linux v5.0 with MySQL.

(2009-12-04 Update: This does not work with RHEL 5.4. The mysql ruby gem requires ruby 1.8.6 and RHEL 5.4 only ships with ruby 1.8.5)

Using yum install ruby and mysql. The command below does not list all the required packages, but due to dependencies, the additional packages will be installed (or should be – this is all from memory).

[bm@app3 ~]$ sudo su -
[root@app3 ~]# yum install ruby ruby-devel ruby-libs ruby-irb \
> ruby-rdoc subversion-ruby mysql-server mysql-devel
[....]

Complete the basic configuration of MySQL.
[root@app3 ~]# /sbin/chkconfig mysqld on
[root@app3 ~]# service mysqld start
[root@app3 ~]# mysql_secure_installation

Download and install RubyGems. As of the date this post was written, the latest version is 1.1.1.
[root@app3 ~]# wget http://rubyforge.org/frs/download.php/35284/rubygems-1.1.1.zip
[root@app3 ~]# unzip rubygems-1.1.1.zip
[root@app3 ~]# cd rubygems-1.1.1
[root@app3 rubygems-1.1.1]# ruby setup.rb
[root@app3 ~]# cd ..
[root@app3 ~]# rm -rf rubygems-1.1.1

Now install Rails, Mongrel, the Ruby MySQL interface, Capistrano
[root@app3 ~]# gem install rails --include-dependencies --no-rdoc --no-ri
[root@app3 ~]# gem install mongrel --include-dependencies --no-rdoc --no-ri
[root@app3 ~]# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
[root@app3 ~]# gem install capistrano --include-dependencies --no-rdoc --no-ri

Phusion’s passenger gem provides a “mod_rails” module for Apache. The installation is very straight forward.
[root@app3 ~]# gem install passenger
[root@app3 ~]# passenger-install-apache2-module

Just follow the on-screen instructions to finish the installation.

Tagged with:
 

13 Responses to “Ruby on Rails for RHEL 5”

  1. Tom says:

    rubygems-1.1.1 requires ruby version 1.8.6 or later… which is not the version in the RHEL5 repos….

  2. Tom says:

    oops, ignore that. the rhel5 ruby is 1.8.5 and the rubygems is looking for 1.8.3+

  3. daniel korenblum says:

    thanks! seems to be working, now if only i could understand where the apache configuration file that passenger wants me to ideit is and what a virtualhost is etc… :-P

  4. Matt says:

    Slick, very slick. Thanks for that. The only stumbling block was the — for gem install mysql, didn’t realize it was required, thought it was a typo.

  5. nate says:

    Handy! One question though… I can’t find a compatible version of subversion-ruby for RHEL5? The version that yum tries to install errors out with this error:

    $ sudo yum -tv install subversion-ruby
    Loading “rhnplugin” plugin
    rhel-i386-server-5 100% |=========================| 1.4 kB 00:00
    Setting up Install Process
    Parsing package install arguments
    Resolving Dependencies
    –> Running transaction check
    —> Package subversion-ruby.i386 0:1.4.2-2.el5 set to be updated
    –> Processing Dependency: subversion = 1.4.2-2.el5 for package: subversion-ruby
    –> Finished Dependency Resolution
    Error: Missing Dependency: subversion = 1.4.2-2.el5 is needed by package subversion-ruby

    Any help greatly appreciated!!!

    Thanks,
    Nate

  6. Alex says:

    Hi.. instead of MySQL, how to install sqlite3 with rails? Can I use rubygems1.2 on this? thanks.

  7. Alex says:

    Failed on gem install mysql. Help!

    # gem install mysql – -with-mysql-config=/usr/bin/mysql_config
    Bulk updating Gem source index for: http://gems.rubyforge.org/
    Building native extensions. This could take a while…
    ERROR: Error installing mysql:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby extconf.rb install mysql – -with-mysql-config=/usr/bin/mysql_config
    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.

  8. Brad says:

    Alex,

    Regarding your mysql gem question, please confirm you have the mysql-dev package installed. You can run the following command:

    # yum install mysql-server mysql-devel

    My instructions were based on a fresh install of RHEL server v 5.0, so if you installed MySQL or any of the other packages from source you may need to do things differently.

    Cheers,

    Brad

  9. Tom McManus says:

    I had the same problem with gem install mysql – -with-mysql-config=/usr/bin/mysql_config and solved it by installing:

    wget ftp://ftp.ntua.gr/pub/databases/mysql/Downloads/MySQL-5.1/MySQL-shared-compat-5.1.29-0

  10. In response to Nate’s question, has anyone been able to figure out why this is happening? I’m also receiving the “Error: Missing Dependency: subversion = 1.4.2-2.el5 is needed by package subversion-ruby” error but cannot figure why this is occurring. Thanks much!

  11. Will says:

    I ran into the same problem as Alex, even with mysql-server and mysql-devel installed. From reading the mkmf.log file, the configurator never tries to look into /usr/lib64/mysql for the libs, despite the mysql_config supplying the right directory, and also despite the command-line option -with-mysql-lib=/usr/lib64/mysql.

    Since it appears that the configurator also tries /usr/local/lib/mysql, I got the package to build by:

    ln -s /usr/lib64/mysql /usr/local/lib/mysql

    Seems to build and install correctly.

    It might be a conflict between the i386 and x86_64 packages. I started running into other problems, so I uninstalled a lot of the i386 stuff, and lo and behold, things started working a lot better.

  12. Ganesh says:

    hi
    Where is the apache configuration file located

  13. Brad says:

    The main apache configuration file is located in /etc/httpd/conf/ and the /etc/httpd/conf.d/ directory also contains some configuration files that are included into the main apache config.

    On Ubuntu, the apache configuration file is located in /etc/apache2/

Leave a Reply