Apache 与 CGI,ApacheCGI


1、安装apache

参考:https://jingyan.baidu.com/article/29697b912f6539ab20de3cf8.html

2、更改httpd.conf

 参考:http://www.jb51.net/article/18993.htm

    ScriptAlias "/cgi-bin/" "E:/Apache24/cgi-bin/"
# "${SRVROOT}/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
<Directory "E:/Apache24/cgi-bin/">
    AllowOverride None
AddHandler cgi-script .pl .cgi .py
    Options All
Order allow,deny
Allow from all
</Directory>

LoadModule access_compat_module modules/mod_access_compat.so(Order 不能用时把这条打卡)


3、写个python脚本

#!E:\Program Files\venv\Scripts\python.exe
# encoding:gb2312
#  import cgi, cgitb
if __name__ == '__main__':
    print 'Content-type: text/html\n\n'
    print("<html>")
    print("<head><title>Hello,python</title></head>")
    a = "100";
    print("<body><h1>hello, i am ")
    print(a)
    print("</h1></body>")
    print("</html>")


4、运行http://127.0.0.1:8088/cgi-bin/脚本名

相关内容

    暂无相关文章