This article mainly introduces how to run Django applications on the Lighttpd server. This article uses the most popular FastCGI module, including the method for running multiple Django applications at the same time, lighttpd (http://www.djangoproject.com/r/lighttpd/) is a lightweight Web server that is usually used to provide access to static pages. It supports FastCGI by nature, so unless your site requires some Apache-specific features, lighttpd is an ideal choice for static and dynamic pages.
Make sure that mod_fastcgi is in the module list. it must appear in mod_rewrite and mod_access, but before mod_accesslog.
Add the following content to your lighttpd configuration file:
server.document-root = "/home/user/public_html"fastcgi.server = ( "/mysite.fcgi" => ( "main" => ( # Use host / port instead of socket for TCP fastcgi # "host" => "127.0.0.1", # "port" => 3033, "socket" => "/home/user/mysite.sock", "check-local" => "disable", ) ),)alias.url = ( "/media/" => "/home/user/django/contrib/admin/media/",)url.rewrite-once = ( "^(/media.*)$" => "$1", "^/favicon\.ico$" => "/media/favicon.ico", "^(/.*)$" => "/mysite.fcgi$1",)
Run multiple Django sites in a lighttpd process
Lighttpd allows you to configure conditions for each site. To support multiple FastCGI sites, you only need to create the condition configuration items for each site in the FastCGI configuration file:
# If the hostname is 'www.example1.com'...$HTTP["host"] == "www.example1.com" { server.document-root = "/foo/site1" fastcgi.server = ( ... ) ...}# If the hostname is 'www.example2.com'...$HTTP["host"] == "www.example2.com" { server.document-root = "/foo/site2" fastcgi.server = ( ... ) ...}
You can also specify multiple portals in fastcgi. server to install multiple Django on the same site. Specify a FastCGI host for each installation.