Difference between revisions of "Lighttpd and FastCGI"

From ArchWiki
Jump to navigation Jump to search
(Fixed thie klapmuetz specific stuff... man this crap was out-of-date.)
Line 2: Line 2:
 
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 and PostgresQL support.
  
NB: I wrote this Step-by-step, so everybody who only needs some parts can quit when he wants to.
 
 
No matter what, you should check out the config at the end!
 
by klapmuetz
 
 
====Set up your /etc/pacman.conf (Optional)====
 
Append those lines to your config.
 
[klapmuetz]
 
Server = http://arch.klapmuetz.org/binaries
 
 
After that you need to sync
 
pacman -Sy
 
 
Or just grab the pkg's from my the server directly or use the PKGBUILD's that you find here: [http://arch.klapmuetz.org ]
 
  
 
====Installing lighttpd and fcgi====
 
====Installing lighttpd and fcgi====
Line 23: Line 9:
  
 
====Installing php-cgi====
 
====Installing php-cgi====
  pacman -S klapmuetz/php
+
  pacman -S php-cgi
Be careful to fetch klapmuetz/php, because the standard Arch one is compiled for command line instead of cgi-fcgi use.
 
Plus this one is compiled for PostgresQL use. Grab the PKGBUILD and recompile it when needed.
 
  
 
Now check if you got the php-cgi version by entering
 
Now check if you got the php-cgi version by entering
''php --version''
+
''php-cgi --version''
 
<pre>
 
<pre>
 
PHP 5.0.4 (cgi-fcgi) (built: May  8 2005 15:08:08)
 
PHP 5.0.4 (cgi-fcgi) (built: May  8 2005 15:08:08)
Line 39: Line 23:
 
Considering you want to use Ruby on Rails I assume you have ruby installed. If not do so.
 
Considering you want to use Ruby on Rails I assume you have ruby installed. If not do so.
  
We need rubygems and ruby-fcgi.
+
We need rubygems and ruby-fcgi. Check the AUR!
  pacman -S ruby-fcgi rubygems
+
  Install both rubygems and ruby-fcgi
 +
 
  
Now we have rubygems. Let's get rails! (Wasn't that hard until now, was it?)
+
Now we have rubygems. Let's get rails!
 
  gem install rails
 
  gem install rails
 
  gem install fcgi
 
  gem install fcgi
Line 88: Line 73:
 
     (
 
     (
 
       "socket" => "/tmp/php-fastcgi.socket",
 
       "socket" => "/tmp/php-fastcgi.socket",
       "bin-path" => "/usr/bin/php"
+
       "bin-path" => "/usr/bin/php-cgi"
 
     )
 
     )
 
   )
 
   )
 
)
 
)
 
</pre>
 
</pre>

Revision as of 17:20, 4 January 2006

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"
    )
  )
)