A simple Apache+fastcgi+django configuration guide

Source: Internet
Author: User
Using Django on Apache and fastcgi, you need to install and configure Apache, and install mod_fastcgi. See Apache and mod_fastcgi Documentation: http://www.djangoproject.com/r/mod_fastcgi/.

When the installation is complete, Apache and Django fastcgi communicate with each other via httpd.conf (Apache configuration file). You need to do two things:

    • Use Fastcgiexternalserver to indicate the location of the fastcgi.
    • Use Mod_rewrite to specify the appropriate URL for fastcgi.

Specify the location of the FastCGI Server

Fastcgiexternalserver tells Apache how to find the FASTCGI server. You can specify the socket or host according to the Fastcgiexternalserver document (http://www.djangoproject.com/r/mod_fastcgi/FastCGIExternalServer/). Here are two examples:

# Connect to FastCGI via a socket/named pipe:fastcgiexternalserver/home/user/public_html/mysite.fcgi-socket/home/user /mysite.sock# Connect to FastCGI via a TCP host/port:fastcgiexternalserver/home/user/public_html/mysite.fcgi-host 127.0.0.1:3033

In these two examples, the/home/user/public_html/directory must exist, and the/home/user/public_html/mysite.fcgi file does not necessarily exist. It is simply an interface used inside a Web server that determines which URLs are fastcgi processed (discussed in detail in the next section). (There will be more on this in the next chapter)
Use mod_rewrite to specify a URL for fastcgi

The second step is to tell Apache to use fastcgi for URLs that conform to a certain pattern. To do this, use the Mod_rewrite module and redirect the URLs to mysite.fcgi (or, as described in the previous article, use any content specified in Fastcgiexternalserver).

In this example, we tell Apache to use fastcgi to handle files that are not available on the file system.

 
  
   
   ServerName example.com documentroot/home/user/public_html Alias/media/home/user/python/django/contrib/admin/media Rewriteengine on Rewriterule ^/(media.*) $/$1 [qsa,l] Rewritecond%{request_filename}!-f rewriterule ^/(. *) $/MYSITE.FCG i/$1 [Qsa,l]
 
  
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.