摘自:
1. 修改/etc/httpd/conf/httpd.conf
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 这一行取消注释(如果这行注释了,用浏览器查看.py的脚本会报403无权限)
-
-
AllowOverride None
-
Options ExecCGI # 注意修改这一行
-
Order allow,deny
-
Allow from all
-
#AddHandler cgi-script .py 其他文章说要有这一行,实测不需要添加
#AddHandler cgi-script .cgi 这一行也无需要取消注释
2. 重启httpd
3. 编写python cgi 脚本
[root@master cgi-bin]# vim pytest.py
4. 在浏览器里输入: DOCUMENT_ROOT
/var/www/html
GATEWAY_INTERFACE
CGI/1.1
HTTP_ACCEPT
text/html, application/xhtml+xml, */*
HTTP_ACCEPT_ENCODING
gzip, deflate
HTTP_ACCEPT_LANGUAGE
zh-CN
HTTP_CONNECTION
Keep-Alive
HTTP_HOST
192.168.1.105
HTTP_USER_AGENT
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; QIHU
THEWORLD)
PATH
/sbin:/usr/sbin:/bin:/usr/bin
QUERY_STRING
REMOTE_ADDR
192.168.1.101
REMOTE_PORT
60819
REQUEST_METHOD
GET
REQUEST_URI
/cgi-bin/pytest.py
SCRIPT_FILENAME
/var/www/cgi-bin/pytest.py
SCRIPT_NAME
/cgi-bin/pytest.py
SERVER_ADDR
192.168.1.105
SERVER_ADMIN
root@localhost
SERVER_NAME
192.168.1.105
SERVER_PORT
80
SERVER_PROTOCOL
HTTP/1.1
SERVER_SIGNATURE
Apache/2.2.15 (CentOS) Server at 192.168.1.105 Port
80
SERVER_SOFTWARE
Apache/2.2.15 (CentOS)
阅读(2051) | 评论(0) | 转发(0) |