Difference between revisions of "Lighttpd and FastCGI"

From ArchWiki
Jump to: navigation, search
m (Minor grammar fixes.)
Line 1: Line 1:
[[Category:Networking (English)]]
[[Category:Networking (English)]]
[[Category:HOWTOs (English)]]
[[Category:HOWTOs (English)]]
This document will describe how to set Ruby on Rails and php up on lighttpd with fastcgi and PostgresQL support.
This document will describe how to set Ruby on Rails and PHP up on lighttpd with fastcgi.
====Installing lighttpd and fcgi====
====Installing lighttpd and fcgi====

Revision as of 19:18, 23 May 2008

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

Template:I18n links start

Template:I18n entry Template:I18n entry Template:I18n links end

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

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

PHP 5.2.5 with Suhosin-Patch (cgi-fcgi) (built: Nov 13 2007 20:03:00)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

If you get a similar output your php is installed successfully

Note : Please keep in mind if you receive errors like No input file found after attempting to access your php files then make sure /etc/php/php.ini has the directives enabled

open_basedir = /home/:/tmp/:/usr/share/pear/:/another/path:/second/path

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


sudo pacman -S rubygems


 wget http://aur.archlinux.org/packages/ruby-fcgi/ruby-fcgi/PKGBUILD
 sudo pacman -U ruby-fcgi-x.x.x-x-xxx.pkg.tar.gz

Now we have rubygems. Let's get rails!

sudo gem install rails --include-dependencies
sudo gem install fcgi --include-dependencies

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
$ 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 have "/site_ruby/" in its path.

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

Configuration of /etc/lighttpd/lighttpd.conf

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

server.modules = (
"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"

Prior to switch on the service, in order to get it fully functional, be sure to create the directory /var/run/lighttpd and set the access accordingly. The Lighttpd installation doesn't create it automatically.


Lighttpd FAQ