Web服务器CGI的配置
CGI程序运行在Web服务器端,Web服务器可以是Apache,Nginx等
GGI程序可以是Python,Ruby,Perl,Shell,C/C++等
配置
apache默认加载cgi模块(若没加载,先加载):
LoadModule cgi_module modules/mod_cgi.so
修改httpd.conf配置中的以下内容:
<Directory "D:/wamp/www/">
...
Options Indexes FollowSymLinks ExecCGI
...
</Directory>
AddHandler cgi-script .cgi .py .pl
注意:以下的内容部分不需要修改
<Directory "D:/wamp/bin/apache/apache2.4.9/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
编写CGI程序
print "Content-type:text/html"
print
print '<html>'
print '<head>'
print '<meta charset="utf-8">'
print '<title>Hello Word - 我的第一个 CGI 程序!</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! 我是来自菜鸟教程的第一CGI程序</h2>'
print '</body>'
print '</html>'
参考
PythonCGI编程
Wamp支持Python CGI
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)