Django

Code

Changeset 3204

Show
Ignore:
Timestamp:
06/25/06 20:18:56 (2 years ago)
Author:
adrian
Message:

More proofreading to docs/fastcgi.txt. Still not finished.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/fastcgi.txt

    r3191 r3204  
    121121 
    122122To use Django with Apache and FastCGI, you'll need Apache installed and 
    123 configured, with mod_fastcgi installed and enabled. Consult the Apache 
     123configured, with `mod_fastcgi`_ installed and enabled. Consult the Apache 
    124124documentation for instructions. 
    125125 
    126 Add the following to your ``httpd.conf``:: 
    127  
    128     # Connect to FastCGI via a socket / named pipe 
     126Once you've got that set up, point Apache at your Django FastCGI instance by 
     127editing the ``httpd.conf`` (Apache configuration) file. You'll need to do two 
     128things: 
     129 
     130    * Use the ``FastCGIExternalServer`` directive to specify the location of 
     131      your FastCGI server. 
     132    * Use ``mod_rewrite`` to point URLs at FastCGI as appropriate. 
     133 
     134.. _mod_fastcgi: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html 
     135 
     136Specifying the location of the FastCGI server 
     137--------------------------------------------- 
     138 
     139The ``FastCGIExternalServer`` directive tells Apache how to find your FastCGI 
     140server. As the `FastCGIExternalServer docs`_ explain, you can specify either a 
     141``socket`` or a ``host``. Here are examples of both:: 
     142 
     143    # Connect to FastCGI via a socket / named pipe. 
    129144    FastCGIExternalServer /home/user/public_html/mysite.fcgi -socket /home/user/mysite.sock 
    130     # Connect to FastCGI via a TCP host/port 
    131     # FastCGIExternalServer /home/user/public_html/mysite.fcgi -host 127.0.0.1:3033 
    132  
    133     <VirtualHost 64.92.160.91> 
    134       ServerName mysite.com 
     145 
     146    # Connect to FastCGI via a TCP host/port. 
     147    FastCGIExternalServer /home/user/public_html/mysite.fcgi -host 127.0.0.1:3033 
     148 
     149In either case, the file ``/home/user/public_html/mysite.fcgi`` doesn't 
     150actually have to exist. It's just a URL used by the Web server internally -- a 
     151hook for signifying which requests at a URL should be handled by FastCGI. (More 
     152on this in the next section.) 
     153 
     154.. _FastCGIExternalServer docs: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer 
     155 
     156Using mod_rewrite to point URLs at FastCGI 
     157------------------------------------------ 
     158 
     159The second step is telling Apache to use FastCGI for URLs that match a certain 
     160pattern. To do this, use the `mod_rewrite`_ module and rewrite URLs to 
     161``mysite.fcgi`` (or whatever you specified in the ``FastCGIExternalServer`` 
     162directive, as explained in the previous section). 
     163 
     164In this example, we tell Apache to use FastCGI to handle any request that 
     165doesn't represent a file on the filesystem and doesn't start with ``/media/``. 
     166This is probably the most common case, if you're using Django's admin site:: 
     167 
     168    <VirtualHost 12.34.56.78> 
     169      ServerName example.com 
    135170      DocumentRoot /home/user/public_html 
    136171      Alias /media /home/user/python/django/contrib/admin/media 
     
    141176    </VirtualHost> 
    142177 
    143 Note that while you have to specify a mysite.fcgi, that this file doesn't 
    144 actually have to exist.  It is just an internal URL to the webserver which 
    145 signifies that any requests to that URL will go to the external FastCGI 
    146 server. 
    147  
    148 LigHTTPd Setup 
     178.. _mod_rewrite: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html 
     179 
     180lighttpd setup 
    149181============== 
    150182 
    151 LigHTTPd is a light-weight asynchronous web-server, which is commonly used 
    152 for serving static files.  However, it supports FastCGI natively, and as such 
    153 is a very good choice for serving both static and dynamic media, if your site 
    154 does not have any apache-specific components. 
     183lighttpd is a light-weight asynchronous Web server commonly used for serving 
     184static files. It supports FastCGI natively, though, and thus is a good choice 
     185for serving both static and dynamic pages, if your site doesn't have any 
     186Apache-specific components. 
    155187 
    156188Make sure ``mod_fastcgi`` is in your modules list, somewhere after 
     
    166198                # Use host / port instead of socket for TCP fastcgi 
    167199                # "host" => "127.0.0.1", 
    168                 # "port" => 3033, 
     200                # "port" => 3033, 
    169201                "socket" => "/home/user/mysite.sock", 
    170202                "check-local" => "disable", 
     
    182214    ) 
    183215 
    184 Running multiple django sites on one LigHTTP
     216Running multiple django sites on one lighttp
    185217--------------------------------------------- 
    186218 
    187 LigHTTPd allows you to use what is called conditional configuration to allow 
     219lighttpd allows you to use what is called conditional configuration to allow 
    188220configuration to be customized per-host.  In order to specify multiple fastcgi 
    189221sites, simply add a conditional block around your fastcgi config for each site::