Ruby on Rails
Fast CGI with Apache2 and RHEL 4 (Version #19)

Note: These docs should work just fine for RHEL(Red

Hat Enterprise Linux) 3, but the apr packages are not necessary in RHEL 3.
  1. Make sure httpd-devel, apr, apr-devel, and apr-util-devel are installed. (if you need to install them, try sudo up2date httpd-devel apr apr-devel apr-util-devel)
  2. Download fcgi and mod_fastcgi
  3. Install fcgi (I use configure --prefix=/usr, but that is entirely optional and against the law in 12 galaxies)
  4. Install mod_fastcgi
    1. cp Makefile.AP2 Makefile
    2. edit Makefile so that top_dir = /usr/lib/httpd, top_builddir = /usr/lib/httpd, and finally INCLUDES=-I /usr/include/httpd -I /usr/include/apr-0
    3. make
    4. make install
  5. Edit /etc/httpd/conf/httpd.conf
    1. Add LoadModule fastcgi_module modules/mod_fastcgi.so
    2. Add

      <IfModule mod_fastcgi.c> FastCgiIpcDir /tmp/fcgi_ipc/ AddHandler fastcgi-script .fcgi </IfModule> </pre>
  6. /sbin/service httpd configtest
  7. /sbin/service httpd restart

If you run into IPC errors, make sure that /tmp/fcgi_ipc is writable by the apache user and group.

Sequence in httpd.conf

A previous version of this document suggested putting the configuration stuff in /etc/httpd/conf.d/fastcgi.conf

However this can lead to problems on RedHat, since the RedHat supplied /etc/httpd/conf/httpd.conf does an Include conf.d/*.conf operation before the User and Group configuration options are set.

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.

Note: These docs should work just fine for RHEL(Red

Hat Enterprise Linux) 3, but the apr packages are not necessary in RHEL 3.
  1. Make sure httpd-devel, apr, apr-devel, and apr-util-devel are installed. (if you need to install them, try sudo up2date httpd-devel apr apr-devel apr-util-devel)
  2. Download fcgi and mod_fastcgi
  3. Install fcgi (I use configure --prefix=/usr, but that is entirely optional and against the law in 12 galaxies)
  4. Install mod_fastcgi
    1. cp Makefile.AP2 Makefile
    2. edit Makefile so that top_dir = /usr/lib/httpd, top_builddir = /usr/lib/httpd, and finally INCLUDES=-I /usr/include/httpd -I /usr/include/apr-0
    3. make
    4. make install
  5. Edit /etc/httpd/conf/httpd.conf
    1. Add LoadModule fastcgi_module modules/mod_fastcgi.so
    2. Add

      <IfModule mod_fastcgi.c> FastCgiIpcDir /tmp/fcgi_ipc/ AddHandler fastcgi-script .fcgi </IfModule> </pre>
  6. /sbin/service httpd configtest
  7. /sbin/service httpd restart

If you run into IPC errors, make sure that /tmp/fcgi_ipc is writable by the apache user and group.

Sequence in httpd.conf

A previous version of this document suggested putting the configuration stuff in /etc/httpd/conf.d/fastcgi.conf

However this can lead to problems on RedHat, since the RedHat supplied /etc/httpd/conf/httpd.conf does an Include conf.d/*.conf operation before the User and Group configuration options are set.

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.