CGI configuration for Linux Python Apache

Source: Internet
Author: User

First, find the directory/usr/local/apache2/conf to install Apache, and modify the httpd.conf configuration file.

1. Loading the CGI module

Remove Comments:

LoadModule cgid_module modules/mod_cgid.so  #//当使用内置模块prefork.c 时动态加载cgi_module

LoadModule cgi_module modules/mod_cgi.so #当使用内置模块worker. C Dynamic Load Cgid_module

2. Set the CGI script file path

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

3. Set access permissions for CGI paths

<directory"/var/www/cgi-bin">   allowoverride None   Options +execcgi   Order Allow, Deny       allow from all </Directory>

4. Set Apache to interpret Python's CGI script file

AddHandler cgi-script. cgi. py

Once these are configured, restart the Apaache.

Second, add CGI script file

Under the/var/www/cgi-bin/directory, create the hello.py file, add the following code, and copy the permissions to chmod 755 hello.py.

#!/usr/bin/env python#-*-coding:utf-8-*- Print "content-type:text/html"PrintPrint ''Print ''Print '<title>Hello</title>'Print ''Print '<body>'Print ''Print '</body>'Print ''

Three-step, browser-accessible

localhost/cgi-bin/hello.py

Reference Document: http://xpleaf.blog.51cto.com/9315560/1740221

Http://www.runoob.com/python/python-cgi.html

CGI configuration for Linux Python Apache

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.