lighttpd + fastcgi of django deployment
This article has been assumed that the correct installation of python and django, system for ubuntu9.04
light footprint + httpd = Lighttpd can be read as Lighty, is a leading German Jan Kneschke developed, based on the open source BSD license WEB server software, and its fundamental purpose is to provide a dedicated web site for high-performance, secure, fast, and compatibility good and flexible web server environment. With very low memory overhead, CPU occupancy rate is low, good performance and a wealth of modules and so on. Lighttpd is a lightweight OpenSource many web server in a relatively good. Support for FastCGI, CGI, Auth, Output compression (output compress), URL rewriting, Alias and other important functions. Therefore very high for those who load the WEB server will be selected Lighttpd is the perfect solution.
1. Install lighttpd
If you use ubuntu, use the command sudo apt-get install lighttpd can. From the source installation methods, as follows:
Extract the installation files (eg: lighttpd-1.5.0-r1691.tar.gz) and switch to the directory in the terminal run:
./configure --prefix=/usr/local/lighttpd make sudo make install
Which the prefix parameter specifies the installation path lighttpd
Configuration after installation:
sudo cp doc/rc.lighttpd /etc/init.d/lighttpd sudo mkdir /etc/lighttpd sudo cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf sudo gedit /etc/init.d/lighttpd
Startup script will be replaced with the ubuntu system, see: http://redmine.lighttpd.net/wiki/1/ScriptsUbuntu
2. Lighttpd configuration
sudo gedit /etc/lighttpd/lighttpd.conf
server.modules: cancellation of the Notes as follows module mod_rewrite, mod_access, mod_fastcgi, mod_simple_vhost, mod_accesslog
Mod_fastcgi which should be in mod_rewrite, mod_access after mod_accesslog before
# server.document-root point to your django project directory
# For example, I in / home / ruby directory django-admin.py startproject mysite, then server.document-root = "/ home / ruby / mysite"
server.document-root = "/ home / ruby / mysite"
fastcgi.server = (
# This file can be mysite.fcgi does not exist, can be named, and below it (url.rewrite-once) consistent
"/ mysite.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
# Django designated redirected to deal with the visit by the Who, where host and port to run the fcgi parameters and the corresponding
# Such as the following parameters to run fcgi:. / Manage.py runfcgi method = threaded host = 127.0.0.1 port = 3033
"host" => "127.0.0.1",
"port" => 3033,
# "socket" => "/ home / ruby / mysite / mysite.sock",
"check-local" => "disable",
)
),
)
alias.url = (
Midia # point to the admin folder, of course, you can master directory in the project folder of the establishment of the symbolic link, the parameters of the project point to the main directory
"/ media /" => "/ path / to / django_home / django / contrib / admin / media /",
)
url.rewrite-once = (
"^ (/ media .*)$" =>" $ 1 ",
"^ / favicon \. ico $" => "/ media / favicon.ico",
"^(/.*)$" => "/ Mysite.fcgi $ 1", # $ 1 is passed to the django's url parameter fcgi
)
3. Configuration has finished, you can run service
sudo /etc/init.d/lighttpd start #启动lighttpd cd /home/ruby/mysite #切到项目路径下 #以线程方式运行fcgi服务,其中host和port参数要和上面lighttpd.conf中定义的一致 ./manage.py runfcgi method=threaded host=127.0.0.1 port=3033
Ok, open the browser, enter http://127.0.0.1, you will be able to see the index page of the
PS: django to http://127.0.0.1/admin and http://127.0.0.1/admin/ different analytical path, / admin / Jump to the normal, and / admin is a jump / mysite.fcgi / admin /, of course, the 404. Usually add settings.py to FORCE_SCRIPT_NAME =''may be forced after the url /
Tags: ruby on rails (RSS), server document (RSS), installation path (RSS), tar gz (RSS), django (RSS), server modules (RSS), fastcgi (RSS), startup script (RSS), fundamental purpose (RSS), perfect solution (RSS), document root (RSS), web server environment (RSS), web server software (RSS), terminal run (RSS), source installation (RSS), license web (RSS), output compression (RSS), occupancy rate (RSS), flexible web (RSS), vhost (RSS)
Permalink: http://www.codeweblog.com/lighttpd-fastcgi-of-django-deployment/





















