apache设置相关:python写CGI http/put目录
2012-01-03 16:45
351 查看
python编写cgi脚本
参考:http://www.tutorialspoint.com/python/python_cgi_programming.htm
1.在apache上设置cgi脚本目录,在http.conf加入下列配置并重启apache
2.编写python的cgi程序
/var/www/bin-cgi/pythoncgi.py
3.通过浏览器访问http://localhost/pythoncgi.py可以看到结果
PS:以上只是一个简单的demo,实际应用都会引入python的cgi模块,可以更方便的解析url参数、环境变量等
另,据说apache的扩展模块mod_python更适合用python编写cgi脚本
设置http/put目录
在http.conf中加入如下配置,即可用http的put方法往/var/www/putdir/目录传文件和写数据
参考:http://www.tutorialspoint.com/python/python_cgi_programming.htm
1.在apache上设置cgi脚本目录,在http.conf加入下列配置并重启apache
<Directory "/var/www/bin-cgi/"> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> AddHandler cgi-script .py
2.编写python的cgi程序
/var/www/bin-cgi/pythoncgi.py
#!/usr/bin/python print "Content-type:text/html\r\n\r\n" print '<html>' print '<head>' print '<title>Hello World - First CGI Program</title>' print '</head>' print '<body>' print '<h2>Hello World! This is my first CGI program</h2>' print '</body>' print '</html>'
3.通过浏览器访问http://localhost/pythoncgi.py可以看到结果
PS:以上只是一个简单的demo,实际应用都会引入python的cgi模块,可以更方便的解析url参数、环境变量等
另,据说apache的扩展模块mod_python更适合用python编写cgi脚本
设置http/put目录
在http.conf中加入如下配置,即可用http的put方法往/var/www/putdir/目录传文件和写数据
<Directory "/var/www/putdir/"> Dav On AllowOverride None Options All Order allow,deny Allow from all </Directory>
相关文章推荐
- 如何设置 Apache HTTP Server 的文件根目录(DocumentRoot)
- apache的相关设置-给目录或者文件设置用户验证
- 【备份】信工apache中有关http.conf的虚拟目录相关配置参考
- 设置 Apache HTTP Server 的文件根目录(DocumentRoot)
- 设置apache支持cgi
- 关于ubuntu下apache虚拟目录的设置问题
- win2003系统下apache、php、mysql安装以及虚拟主机和目录权限设置(转载)
- 设置修改 Apache 文件根目录 (Document Root)
- Apache设置反向代理等相关备注
- Linux下Apache网站目录读写权限的设置
- Apache Web 服务器配置CGI程序,执行Python、Perl脚本
- python配置apache的web服务器方法(python的CGI配置)
- window下如何配置apache Http服务器使其能运行python cgi脚本
- python pip通过本地目录安装相关程序包
- Python设置http的header请求访问URL
- Linux Apache服务器相关的重要目录
- apache设置一个目录被访问
- VS工程目录设置相关问题详解
- apache设置目录访问权限
- Linux系统下Apache日志文件设置、更改默认网站目录、防止php木马跨站设置、禁止空主机头