cgi配置:apache2.4与apache2.2区别
2017-05-16 15:03
423 查看
相同点:
1.在安装目录apache下找到文件httpd.conf,检查以下代码是否前面有#,如果有就去掉
2.查看并修改一下代码中的路径,与下面的第4点中的路径一致
3.找到一下代码添加.py .exe等你需要的执行文件格式
不同点:
4.找到类似下面的代码块(里面的路径改为自己的安装路径,我这里是一个集成环境)
apache2.4修改为:
在apache2.2中则改为
5.举一个python的例子,创建文件hello.py,文件内容如下:
注意:注释中的路径一定要改好
浏览器输入localhost/cgi-bin/hello.py
结果:
1.在安装目录apache下找到文件httpd.conf,检查以下代码是否前面有#,如果有就去掉
LoadModule cgi_module modules/mod_cgi.so
2.查看并修改一下代码中的路径,与下面的第4点中的路径一致
ScriptAlias /cgi-bin/ "D:/SoftWare/XAMPP/cgi-bin/"
3.找到一下代码添加.py .exe等你需要的执行文件格式
AddHandler cgi-script .cgi .pl .asp .py .exe
不同点:
4.找到类似下面的代码块(里面的路径改为自己的安装路径,我这里是一个集成环境)
# # "D:/SoftWare/XAMPP/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory "D:/SoftWare/XAMPP/cgi-bin"> AllowOverride None Options None Require all granted </Directory>
apache2.4修改为:
<Directory "D:/SoftWare/XAMPP/cgi-bin"> AllowOverride None Options Indexes FollowSymLinks ExecCGI Require all granted Require host ip </Directory>
在apache2.2中则改为
<Directory "D:/SoftWare/XAMPP/cgi-bin"> AllowOverride None Options +ExecCGI Order allow,deny Allow from all </Directory>
5.举一个python的例子,创建文件hello.py,文件内容如下:
注意:注释中的路径一定要改好
#!D:\SoftWare\python3.6\python.exe #linux一般为#!usr/bin/python # -*- coding: utf-8 -*- print "Content-type:text/html" print # 空行,告诉服务器结束头部 print '<html>' print '<head>' print '<meta charset="utf-8">' print '<title>Hello Word!</title>' print '</head>' print '<body>' print '<h2>Hello Word!</h2>' print '</body>' print '</html>'将该文件放到cgi-bin目录下,
浏览器输入localhost/cgi-bin/hello.py
结果:
相关文章推荐
- apache 2.2 和2.4 配置虚拟域名的区别
- Apache2.4和Apache2.2访问控制配置语法对比
- httpd2.2和http2.4的配置https的区别
- Apache2.2和2.4配置的几个差异
- Ubuntu 14.02下编译及配置apache2.4(python CGI)
- Apache2.2配置CGI
- apache 2.2 和2.4 目录权限访问设置的区别
- Apache 2.2和升级版2.4的httpd.conf配置差别总结
- Apache2.2配置CGI
- Apache2.4和Apache2.2访问控制配置比较
- apache2.2 到 2.4后配置文件需要更改的部分
- apache2.2+perl/cgi的正确配置
- Apache2.4和Apache2.2访问控制配置语法对比
- apache2.4和2.2 的一些区别
- Apache2.2和Apache2.4中httpd.conf配置文件的异同
- Apache2.2和Apache2.4中httpd.conf配置文件 权限的异同
- 总结apache2.2和2.4和tomcat负载均衡配置和总结。
- Apache2.2和Apache2.4中httpd.conf配置文件的异同
- apache2.2 到 2.4后配置文件需要更改的部分
- php 多虚拟主机配置(apache2.2+2.4)