Installing Typo on Fedora Core 2 with Ensim Control Panel -- Part 1

Typo is a weblog application using the well known Ruby on Rails framework.

These are my notes as I remember on installation of Typo on FC2 with Ensim Control Panel...
(Ensim Pro 4.1.0-8.fc.2 )

This is the first part of a series of notes which will cover the preparation of what I need to get Typo up and running:

  • Install ruby.
  • Install gem.
  • Install rails.
  • Install mysql ruby binding.
  • Install the fcgi libraries.
  • Install mod_fcgi apache module.
  • Install fastcgi ruby binding.
  • Install and setup Typo.

Process

  1. Download the current gzipped tarball of Ruby and install it.
    $ wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gz
    $ tar -xvzf ruby-1.8.4.tar.gz
    $ cd ruby-1.8.4
    $ ./configure --prefix=/usr
    $ make
    # make install
    
  2. Download the current RubyGems tarball and install it.
    $ wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
    $ tar -xvzf rubygems-0.8.11.tgz
    $ cd rubygems-0.8.11
    # ruby setup.rb
    
  3. Insall rails via gem.
    # gem update
    # gem install rails
    
  4. Install mysql Ruby binding:.
    # gem install mysql
    
  5. Ensim should already have mod_fastcgi but Apache hasn't been setup to use it.

    If it does not have it already, you need to install the fcgi libraries and the mod_fastcgi module.

    Install fcgi libraries:

    $ wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
    $ tar -xvzf fcgi-2.4.0.tar.gz
    $ cd fcgi-2.4.0
    $ ./configure
    $ make 
    # make install
    
  6. Install mod_fastcgi module:
    $ wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
    $ tar -xvzf mod_fastcgi-2.4.2.tar.gz
    $ cd mod_fastcgi-2.4.2
    $ cp Makefile.AP2 Makefile
    $ make top_dir=/usr/lib/httpd
    # make install
    
  7. Load the module and add the FastCGI handler to the "httpd.conf" file.
    LoadModule fastcgi_module modules/mod_fastcgi.so
    <IfModule mod_fastcgi.c>
      FastCgiIpcDir /tmp/fcgi_ipc/
      AddHandler fastcgi-script .fcgi
    </IfModule>
    

    NOTE: Since "/etc/httpd/conf/httpd.conf" does an Include conf.d/*.conf operation before the User and Group configuration options are set, do not add the handlers to conf.d directory.

    As a result, the IPC Directory is created by root, and is inaccessible to user who runs the web server, which is specified in the User directive.

    This results in the following types of errors when starting, or restarting the server:

    FastCgiIpcDir /tmp/fcgi_ipc: access for server (uid -1, gid -1) failed
    

    To avoid this problem, ensure that the User and Group are set before the FastCgiIpcDir directive.

  8. That's all that needs to be done with Apache, so restart it:
    # service httpd restart
    
  9. Install the FastCGI Ruby binding:
    # gem install fcgi -- --with-fcgi-include=/usr/local/include
    --with-fcgi-lib=/usr/local/lib
    

    Note the double dashes after fcgi is not a typo.

  10. Now that we have prepared Apache and Ruby, to use fastcgi and mysql, we can go ahead and install Typo as mentioned in the installation notes.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Typo and CPU load

One thing that I learnt today was that typo is heavy on the cpu if not deployed as 'production'.

By default Typo is distributed for development. I needed to Uncomment the line that mentions:

ENV['RAILS_ENV'] = 'production'

So if you aren't doing development work, suggest making the above change in the 'config/environment.rb' file.

Tuning FastCGI for Rails Application on Apache

Configure FastCGI to use a static server definition with the "FastCgiServer" directive -- which ensures that fcgi listeners are available upon apache being started.

<IfModule mod_fastcgi.c>
    FastCgiIpcDir /tmp/fcgi_ipc/
    FastCgiServer /path/to/app/public/dispatch.fcgi \ 
      -idle-timeout 120  -processes 2 \
      -initial-env RAILS_ENV=production
    AddHandler fastcgi-script .fcgi
</IfModule>

Note the full path to "dispatch.fcgi" should be the same as when a dynamic server is run, so find out the full path to the dispatcher prior to adding the static directive else it may still be running dynamically.

$ ps auxw | awk '/dispatch.fcgi/ {print $12}'

The "-idle-timeout" parameter is important in case of application timing out with slow response times in which case Apache will assume FastCGI crashed and return 500 errors.

2 running processes should be quite sufficient and may be increased for high traffic site to 3 or 4 times the number of CPU, which may give a better performance.

Comment