How to run a Django application on the Lighttpd server

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.