Fedora

How to Install Ruby on Rails using MySQL 5 for Apache 2 on Fedora Core 6

Be ready to hate Ruby on Rails. I’m learning the hard way so you don’t have to. Hopefully this page will help you. This how-to assumes you know how to use a root account, how to configure and install applications, and how to configure Apache. Use the root account for the following or prefix every command with sudo.

  1. Get some packages using Yum


    yum install ruby ruby-devel ruby-rdoc ruby-irb ruby-ri httpd-devel sqlite2-devel mysql-devel

  2. Download, compile, and install FastCGI and its Apache module

    FastCGI: http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
    Module for Apache 2: http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
    Decompress them and do the usual “configure, make, make install” procedure.

  3. Get some packages using Gem


    gem install rails fcgi sqlite

    Don’t forget the binding for MySQL:

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

  4. Update and reload configuration of Apache

    Create a new file in /usr/httpd/conf.d called fastcgi.conf with the following content:

    LoadModule fastcgi_module modules/mod_fastcgi.so

    FastCgiIpcDir /tmp/fcgi_ipc/
    AddHandler fastcgi-script .fcgi


    Create above-mentioned directory and set its permissions:

    mkdir /tmp/fcgi_ipc
    chmod -R 777 /tmp/fcgi_ipc

    When you’re done, reload the configuration:

    service httpd reload

  5. Create and configure a Ruby application directory

    Create an application directory. In this example, we’ll call it rubyapp:

    ruby /path/to/rubyapp
    cd /path/to/rubyapp

    Modify the public/.htaccess file and remove or comment out the following line:

    #RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

    And add the following:

    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

    In the config/environment.fb file, uncomment the following line:

    ENV['RAILS_ENV'] ||= 'production'

  6. View your Ruby application with a browser

    Make sure the public directory is served by Apache. This should be the only directory viewable in a Web browser. For example, let’s assume http://localhost/rubyapp/ points to /path/to/rubyapp/public. By going to that address, you should read a “Welcome aboard!” page. Read the instructions on that page to finish the set-up.

  7. Let the Ruby application use MySQL instead of SQLite

    Modify config/database.yml. Replace the production section with the following:

    production:
    adapter: mysql
    database: [databasename]
    username: [username]
    password: [password]
    timeout: 5000

One page that helped me:

Background image