Lighttpd and FastCGI
From ArchWiki
This document will describe how to set Ruby on Rails and PHP up on lighttpd with fastcgi.
| i18n |
|---|
| English |
| Español |
Contents |
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.3.0 with Suhosin-Patch (cgi-fcgi) (built: Sep 27 2009 22:01:58) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 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:
cgi.fix_pathinfo=1 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!
Rubygems
$ sudo pacman -S rubygems
ruby-fcgi
$ wget http://aur.archlinux.org/packages/ruby-fcgi/ruby-fcgi/PKGBUILD $ makepkg $ 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-dependenciesIf this fails, run
# pacman -S fcgior get [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 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_access",
"mod_fastcgi",
"mod_accesslog" )
server.indexfiles = ( "dispatch.fcgi", "index.php" ) #dispatch.fcgi if 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"
)
)
)