Django

Code

Show
Ignore:
Timestamp:
06/17/07 17:18:54 (2 years ago)
Author:
clong
Message:

per-object-permissions: Merged to trunk [5486] NOTE: Not fully tested, will be working on this over the next few weeks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/per-object-permissions/docs/fastcgi.txt

    r3810 r5488  
    1 ============================== 
    2 How to use Django with FastCGI 
    3 ============================== 
     1=========================================== 
     2How to use Django with FastCGI, SCGI or AJP 
     3=========================================== 
    44 
    55Although the `current preferred setup`_ for running Django is Apache_ with 
    6 `mod_python`_, many people use shared hosting, on which FastCGI is the only 
    7 viable option. In some setups, FastCGI also allows better security -- and, 
    8 possibly, better performance -- than mod_python. 
     6`mod_python`_, many people use shared hosting, on which protocols such as 
     7FastCGI, SCGI or AJP are the only viable options. In some setups, these protocols 
     8also allow better security -- and, possibly, better performance -- than mod_python. 
     9 
     10.. admonition:: Note 
     11 
     12    This document primarily focuses on FastCGI. Other protocols, such as SCGI 
     13    and AJP, are also supported, through the ``flup`` Python package. See the 
     14    "Protocols" section below for specifics about SCGI and AJP. 
    915 
    1016Essentially, FastCGI is an efficient way of letting an external application 
     
    1824persistent process. 
    1925 
    20 .. _current preferred setup: http://www.djangoproject.com/documentation/modpython/ 
     26.. _current preferred setup: ../modpython/ 
    2127.. _Apache: http://httpd.apache.org/ 
    2228.. _mod_python: http://www.modpython.org/ 
     
    7581list of all the available options. 
    7682 
    77 You'll need to specify either a ``socket`` or both ``host`` and ``port``. Then, 
    78 when you set up your Web server, you'll just need to point it at the host/port 
     83You'll need to specify either a ``socket``, ``protocol`` or both ``host`` and ``port``. 
     84Then, when you set up your Web server, you'll just need to point it at the host/port 
    7985or socket you specified when starting the FastCGI server. 
     86 
     87Protocols 
     88--------- 
     89 
     90Django supports all the protocols that flup_ does, namely fastcgi_, `SCGI`_ and 
     91`AJP1.3`_ (the Apache JServ Protocol, version 1.3). Select your preferred 
     92protocol by using the ``protocol=<protocol_name>`` option with 
     93``./manage.py runfcgi`` -- where ``<protocol_name>`` may be one of: ``fcgi`` 
     94(the default), ``scgi`` or ``ajp``. For example:: 
     95 
     96    ./manage.py runfcgi --protocol=scgi 
     97 
     98.. _flup: http://www.saddi.com/software/flup/ 
     99.. _fastcgi: http://www.fastcgi.com/ 
     100.. _SCGI: http://python.ca/scgi/protocol.txt 
     101.. _AJP1.3: http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html 
    80102 
    81103Examples 
     
    182204      Alias /media /home/user/python/django/contrib/admin/media 
    183205      RewriteEngine On 
    184       RewriteRule ^/(media.*)$ /$1 [QSA,L
     206      RewriteRule ^/(media.*)$ /$1 [QSA,L,PT
    185207      RewriteCond %{REQUEST_FILENAME} !-f 
    186208      RewriteRule ^/(.*)$ /mysite.fcgi/$1 [QSA,L] 
     
    275297Then, create a small script that tells Apache how to spawn your FastCGI 
    276298program. Create a file ``mysite.fcgi`` and place it in your Web directory, and 
    277 be sure to make it executable :: 
     299be sure to make it executable:: 
    278300 
    279301    #!/usr/bin/python 
     
    305327 
    306328    touch mysite.fcgi 
     329 
     330Serving admin media files 
     331========================= 
     332 
     333Regardless of the server and configuration you eventually decide to use, you will 
     334also need to give some thought to how to serve the admin media files. The 
     335advice given in the modpython_ documentation is also applicable in the setups 
     336detailed above. 
     337 
     338.. _modpython: ../modpython/#serving-the-admin-files 
     339