Python uses CGI under Ubuntu system apache2

Source: Internet
Author: User

ubuntu15.10 system

The Ubuntu system's apache2 setup file is different from other systems and is scattered over several files.

/etc/apache2/conf-enabled/serve-cgi-bin.conf file: Scriptalias is the directory where the CGI files are to be set

1<ifmodule mod_alias.c>2<ifmodule mod_cgi.c>3 Define Enable_usr_lib_cgi_bin4</IfModule>5 6<ifmodule mod_cgid.c>7 Define Enable_usr_lib_cgi_bin8</IfModule>9 Ten<ifdefine enable_usr_lib_cgi_bin> Onescriptalias/cgi-bin//var/www/cgi-bin/ A<directory"/var/www/cgi-bin"> - allowoverride None -Options +execcgi-multiviews +SymLinksIfOwnerMatch the Require All granted -</Directory> -</IfDefine> -</IfModule> +  -# Vim:syntax=apache Ts=4sw=4sts=4SR Noet

/etc/apache2/mods-enabled/cgi.load files: setting apache2 loading CGI

LoadModule cgi_module/usr/lib/apache2/modules/mod_cgi.so

Restart Apache2

sudo service apache2 restart

If 403,/etc/apache2/apache2.conf appears, Directionary is set to Require all granted

Python CGI file code example:

#!/usr/bin/python3print ('content-type:text/html\n\n') print ('  ')
Content-type Required Items

/etc/apache2/sites-enabled/000-default.conf file, you can set the DocumentRoot

Python uses CGI under Ubuntu system apache2

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.