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