最近学习python, 想了解一下Python下CGI程序的运行,却发现相关中文资料并不是特别多,于是简单谢谢
1. 安装httpd
# yum -y install httpd
可以设置成自动运行
# chkconfig httpd on
启动httpd
# service httpd start
2. 安装Python
# yum -y install python
3. 配置httpd
需要对配置文件做一定配置
# vim /etc/httpd/conf/httpd.conf
确保这条语句在
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
在这里需要设置Options 成ExecCGI
<Directory "/var/www/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
如果需要CGI服务器处理除,cgi之外的后缀, 比如.py(oython文件), pl(perl)文件, .sh(shell文件), 需要修改一下这个项
AddHandler cgi-script .cgi .py .pl .sh
配置完成之后重启httpd
# service httpd restart
4. 编写cgi文件
进入/var/www/