Lighttpd and FastCGI

From ArchWiki
Revision as of 17:20, 4 January 2006 by Klapmuetz (talk | contribs) (Fixed thie klapmuetz specific stuff... man this crap was out-of-date.)
Jump to navigation Jump to search

This document will describe how to set Ruby on Rails and php up on lighttpd with fastcgi and PostgresQL support.


Installing lighttpd and fcgi

pacman -S lighttpd fcgi

Now you have lighttpd with fcgi support. If it was that what you wanted you're all set. People that want Ruby on Rails and/or php should continue.

Installing php-cgi

pacman -S php-cgi

Now check if you got the php-cgi version by entering php-cgi --version

PHP 5.0.4 (cgi-fcgi) (built: May  8 2005 15:08:08)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies

If you get the same output your php is installed successfully

Ruby on Rails related

Considering you want to use Ruby on Rails I assume you have ruby installed. If not do so.

We need rubygems and ruby-fcgi. Check the AUR!

Install both rubygems and ruby-fcgi


Now we have rubygems. Let's get rails!

gem install rails
gem install fcgi

If this fails, get the [1] and compile it yourself.

$ wget http://fastcgi.com/dist/fcgi.tar.gz
$ tar zxvf fcgi.tar.gz
$ cd fcgi-2.4.0
$./configure
$ make
# make install

And repeat the gem install.

Check if you have more than one fcgi.so

find /usr -name fcgi.so

If you have two, delete the one that doesn't has "/site_ruby/" in his path.

For documentation how to use Ruby on Rails please consult [2].

Configuration of /etc/lighttpd.conf

I only show those you should change. The config is well commented and documentation can be found on [3].

server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )

server.indexfiles = ( "dispatch.fcgi", "index.php" ) #dispatch.fcgi is rails specified

server.error-handler-404   = "/dispatch.fcgi" #too

fastcgi.server = (
".fcgi" =>
  ( "localhost" =>
    (
      "socket" => "/tmp/rails-fastcgi.socket",
      "bin-path" => "/path/to/rails/application/public/dispatch.fcgi"
    )
  ),
".php" =>
  ( "localhost" =>
    (
      "socket" => "/tmp/php-fastcgi.socket",
      "bin-path" => "/usr/bin/php-cgi"
    )
  )
)