在Lighttpd服务器中运行Django应用的方法,lighttpddjango
在Lighttpd服务器中运行Django应用的方法,lighttpddjango
lighttpd (http://www.djangoproject.com/r/lighttpd/) 是一个轻量级的Web服务器,通常被用来提供静态页面的访问。 它天生支持FastCGI,因此除非你的站点需要一些Apache特有的特性,否则,lighttpd对于静态和动态页面来说都是理想的选择。
确保 mod_fastcgi 在模块列表中,它需要出现在 mod_rewrite 和 mod_access ,但是要在 mod_accesslog 之前。
将下面的内容添加到你的lighttpd的配置文件中:
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", )
在一个lighttpd进程中运行多个Django站点
lighttpd允许你使用条件配置来为每个站点分别提供设置。 为了支持FastCGI的多站点,只需要在FastCGI的配置文件中,为每个站点分别建立条件配置项:
# 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 = ( ... ) ... }
你也可以通过 fastcgi.server 中指定多个入口,在同一个站点上实现多个Django安装。 请为每一个安装指定一个FastCGI主机。
相关内容
- 在主机商的共享服务器上部署Django站点的方法,django站
- 在Python的Django框架中生成CSV文件的方法,
- 利用Python的Django框架生成PDF文件的教程,
- 用Python的Django框架来制作一个RSS阅读器,pythondjango
- 在Django中使用Sitemap的方法讲解,djangositemap
- 详解Python的Django框架中的Cookie相关处理,pythondjango
- 在Django中创建URLconf相关的通用视图的方法,djangourlco
- Django框架中处理URLconf中特定的URL的方法,djangourlconf
- Python的Django框架中从url中捕捉文本的方法,
- Django中URL视图函数的一些高级概念介绍,djangourl视图函
评论关闭