Django

Code

Changeset 3209

Show
Ignore:
Timestamp:
06/26/06 07:30:29 (2 years ago)
Author:
adrian
Message:

Finished proofreading docs/fastcgi.txt

Files:

Legend:

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

    r3204 r3209  
    181181============== 
    182182 
    183 lighttpd is a light-weight asynchronous Web server commonly used for serving 
    184 static files. It supports FastCGI natively, though, and thus is a good choice 
    185 for serving both static and dynamic pages, if your site doesn't have any 
    186 Apache-specific components. 
     183lighttpd is a lightweight Web server commonly used for serving static files. It 
     184supports FastCGI natively and, thus, is a good choice for serving both static 
     185and dynamic pages, if your site doesn't have any Apache-specific needs. 
    187186 
    188187Make sure ``mod_fastcgi`` is in your modules list, somewhere after 
    189 mod_rewrite and mod_access, but not after mod_accesslog.  You'll probably 
    190 want mod_alias as well, for serving admin media. 
     188``mod_rewrite`` and ``mod_access``, but not after ``mod_accesslog``. You'll 
     189probably want ``mod_alias`` as well, for serving admin media. 
    191190 
    192191Add the following to your lighttpd config file:: 
     
    214213    ) 
    215214 
    216 Running multiple django sites on one lighttpd 
     215Running multiple Django sites on one lighttpd 
    217216--------------------------------------------- 
    218217 
    219 lighttpd allows you to use what is called conditional configuration to allow 
    220 configuration to be customized per-host.  In order to specify multiple fastcgi 
    221 sites, simply add a conditional block around your fastcgi config for each site:: 
    222  
    223     $HTTP["host"] == "www.website1.com" { 
     218lighttpd lets you use "conditional configuration" to allow configuration to be 
     219customized per host. To specify multiple FastCGI sites, just add a conditional 
     220block around your FastCGI config for each site:: 
     221 
     222    # If the hostname is 'www.example1.com'... 
     223    $HTTP["host"] == "www.example1.com" { 
    224224        server.document-root = "/foo/site1" 
    225225        fastcgi.server = ( 
     
    229229    } 
    230230 
    231     $HTTP["host"] == "www.website2.com" { 
     231    # If the hostname is 'www.example2.com'... 
     232    $HTTP["host"] == "www.example2.com" { 
    232233        server.document-root = "/foo/site2" 
    233234        fastcgi.server = ( 
     
    237238    } 
    238239 
    239 You can also run multiple django installations on the same site simply by 
    240 specifying multiple entries in the ``fastcgi.server`` directive, add one 
    241 fastcgi host for each. 
    242  
    243 Running Django on a shared-hosting provider 
    244 =========================================== 
    245  
    246 For many users on shared-hosting providers, you aren't able to run your own 
    247 server daemons nor do they have access to the httpd.conf of their webserver. 
    248 However, it is still possible to run Django using webserver-spawned processes. 
     240You can also run multiple Django installations on the same site simply by 
     241specifying multiple entries in the ``fastcgi.server`` directive. Add one 
     242FastCGI host for each. 
     243 
     244Running Django on a shared-hosting provider with Apache 
     245======================================================= 
     246 
     247Many shared-hosting providers don't allow you to run your own server daemons or 
     248edit the ``httpd.conf`` file. In these cases, it's still possible to run Django 
     249using Web server-spawned processes. 
    249250 
    250251.. admonition:: Note 
    251252 
    252     If you are using webserver-managed processes, there's no need for you 
    253     to start the FastCGI server on your own.  Apache will spawn a number 
    254     of processes, scaling as it needs to. 
    255  
    256 In your web root directory, add this to a file named .htaccess :: 
     253    If you're using Web server-spawned processes, as explained in this section, 
     254    there's no need for you to start the FastCGI server on your own. Apache 
     255    will spawn a number of processes, scaling as it needs to. 
     256 
     257In your Web root directory, add this to a file named ``.htaccess`` :: 
    257258 
    258259    AddHandler fastcgi-script .fcgi 
     
    261262    RewriteRule ^/(.*)$ /mysite.fcgi/$1 [QSA,L] 
    262263 
    263 Now you must add a small shim script in order for apache to properly 
    264 spawn your FastCGI program.  Create a mysite.fcgi and place it in your 
    265 web directory, making it executable :: 
     264Then, create a small script that tells Apache how to spawn your FastCGI 
     265program. Create a file ``mysite.fcgi`` and place it in your Web directory, and 
     266be sure to make it executable :: 
    266267 
    267268    #!/usr/bin/python 
    268269    import sys, os 
    269270 
    270     # add a custom pythonpath 
     271    # Add a custom Python path. 
    271272    sys.path.insert(0, "/home/user/python") 
    272273 
    273     # switch to the directory of your project. (optional
     274    # Switch to the directory of your project. (Optional.
    274275    # os.chdir("/home/user/myproject") 
    275276 
    276     # change to the name of your app's settings module 
     277    # Set the DJANGO_SETTINGS_MODULE environment variable. 
    277278    os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" 
    278279 
     
    283284----------------------------- 
    284285 
    285 If you change the code of your site, to make apache re-load your django 
    286 application, you do not need to restart the server.  Simply re-upload or 
    287 edit your ``mysite.fcgi`` in such a way that the timestamp on the fil
    288 will change.  When apache sees that the file has been updated, it will 
    289 restart your django application for you. 
    290  
    291 If you have access to a command shell on a unix system, restarting the 
    292 server can be done with the ``touch`` command:: 
     286If you change any Python code on your site, you'll need to tell FastCGI the 
     287code has changed. But there's no need to restart Apache in this case. Rather, 
     288just reupload ``mysite.fcgi``, or edit the file, so that the timestamp on th
     289file will change. When Apache sees the file has been updated, it will restart 
     290your Django application for you. 
     291 
     292If you have access to a command shell on a Unix system, you can accomplish this 
     293easily by using the ``touch`` command:: 
    293294 
    294295    touch mysite.fcgi