Next: Starting Web Applications Manually, Previous: Deploying on Apache, Up: Working With Web Applications
These instructions explain how to deploy a compiled web application on the lighttpd web server.
Before following these instructions, please make sure that mod_fastcgi is enabled in lighttpd, as described here: Installing FastCGI.
You will need mod_rewrite, which is a standard module distributed with lighttpd, enabled in your lighttpd server to deploy the compiled web application. To enable mod_rewrite, make sure it is listed in the server.modules section of your lighttpd.conf
It is typical to use a cgi-bin directory for FastCGI binaries. This may be any suitable place on your server, but should not be a directory underneith your web document root (for security reasons).
cp myapp.fcgi libmyapp_u.so /usr/lib/cgi-bin/
TIP: If you are updating a web application that is already running, you may need to remove the previous version first, because your operating system won't let you change the contents of an executable that is currently running.
Your web application will need a “web root” directory where the static content such as images are stored. In the first example, we will use the directory /var/www/myapp/.
We use the mod_rewrite module to grab all requests for PHP files in the application's web root directory and re-route them to the FastCGI binary. We also allow for an index.php file. This is an example lighttpd configuration section which says roughly “pass all requests for files that end in .php in the directory /var/www/myapp/ on to /cgi-bin/myapp.fcgi”:
# serve index pages url.rewrite-once = ( "^/myapp/$" => "/myapp/index.php" ) # main fastcgi entry $HTTP["url"] =~ "^/myapp/.+\.php$" { fastcgi.server = ( "/myapp" => ( "localhost" => ( "bin-path" => "/var/www/localhost/cgi-bin/myapp.fcgi", "docroot" => "/var/www/localhost/htdocs/myapp", "host" => "127.0.0.1", "port" => 1026, "check-local" => "disable" ) ) ) } # HTTP[url]
For more information and options on configuring the application, including load balancing and number of processes, consult the lighttpd FastCGI documentation.