Record the fastcgi + python configuration process In debian

Source: Internet
Author: User
Record the fastcgi + python configuration process In debian-Debian information in the Linux release. The following is a detailed description. First install fastcgi first
Apt-get install libapach2-mod-fcgid

If you need to support php and other features, you can install php. Apt-get install php5-cgi

Modify the fcgid configuration file of apache:/etc/apache2/mod-enabled/fcgid. conf

AddHandler fcgid-script. php. py. pl. fcgi
SocketPath/var/lib/apache2/fcgid/sock
IPCConnectTimeout 20


By the way, php, perl, and so on are supported.

Modify the apache site configuration file default and add the script directory.

ScriptAlias/cgi-bin // var/www/cgi-bin/

DirectoryIndex index.html index. py
AllowOverride None
Options ExecCGI-MultiViews + SymLinksIfOwnerMatch
Order allow, deny
Allow from all


All right. Restart apache2 and try again.

/Etc/init. d/apache2 restart

Next, place a test file in/var/www/cgi-bin, for example, index. py, as shown below:

#! /Usr/bin/python

Try:
From fcgi import WSGIServer

Def myapp (environ, start_response ):
Start_response ('2014 OK ', [('content-type', 'text/plain')])
Return ['Hello World! \ N']

WSGIServer (myapp). run ()

Except t Exception, e:
Print 'content-Type: text/plain \ r \ n \ r \ n ',
Print 'oops ...'
Print
Print 'trac detected an internal error :'
Print
Print e
Print

It must be noted that fcgi. py must be placed in the current path of index. py; otherwise, it cannot be found.

If fcgi. py cannot be found, you can go to the following link:

Wget http://svn.saddi.com/py-lib/trunk/fcgi.py
Index. py must have the following execution permissions:

Chmod 755 index. py

OK. Open it in the browser and you will be able to see Hello World.

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.