| 126 | | Add the following to your ``httpd.conf``:: |
|---|
| 127 | | |
|---|
| 128 | | # Connect to FastCGI via a socket / named pipe |
|---|
| | 126 | Once you've got that set up, point Apache at your Django FastCGI instance by |
|---|
| | 127 | editing the ``httpd.conf`` (Apache configuration) file. You'll need to do two |
|---|
| | 128 | things: |
|---|
| | 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 | |
|---|
| | 136 | Specifying the location of the FastCGI server |
|---|
| | 137 | --------------------------------------------- |
|---|
| | 138 | |
|---|
| | 139 | The ``FastCGIExternalServer`` directive tells Apache how to find your FastCGI |
|---|
| | 140 | server. 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. |
|---|
| 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 | |
|---|
| | 149 | In either case, the file ``/home/user/public_html/mysite.fcgi`` doesn't |
|---|
| | 150 | actually have to exist. It's just a URL used by the Web server internally -- a |
|---|
| | 151 | hook for signifying which requests at a URL should be handled by FastCGI. (More |
|---|
| | 152 | on this in the next section.) |
|---|
| | 153 | |
|---|
| | 154 | .. _FastCGIExternalServer docs: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiExternalServer |
|---|
| | 155 | |
|---|
| | 156 | Using mod_rewrite to point URLs at FastCGI |
|---|
| | 157 | ------------------------------------------ |
|---|
| | 158 | |
|---|
| | 159 | The second step is telling Apache to use FastCGI for URLs that match a certain |
|---|
| | 160 | pattern. To do this, use the `mod_rewrite`_ module and rewrite URLs to |
|---|
| | 161 | ``mysite.fcgi`` (or whatever you specified in the ``FastCGIExternalServer`` |
|---|
| | 162 | directive, as explained in the previous section). |
|---|
| | 163 | |
|---|
| | 164 | In this example, we tell Apache to use FastCGI to handle any request that |
|---|
| | 165 | doesn't represent a file on the filesystem and doesn't start with ``/media/``. |
|---|
| | 166 | This 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 |
|---|
| 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. |
|---|
| | 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. |
|---|