一、apache支持的语言

html

在(一)(二)Apache的配置中,都是html的例子

php

  1. 编写php测试页

windows apache部署python_php

windows apache部署python_php_02

  1. 安装php

windows apache部署python_重启_03

此时可以看到子配置目录下有php.conf这个文件

windows apache部署python_重启_04

  1. 重启服务

windows apache部署python_html_05

  1. 测试

cgi

1.在/var/www/cgi-bin/目录下建立并编辑访问文件

windows apache部署python_重启_06

windows apache部署python_重启_07

2.给文件添加可执行的权限

windows apache部署python_html_08

3.测试

windows apache部署python_php_09

注意事项:
在目录出错和安全上下文不匹配的情况下,会出错,如下

在其他目录下新建并编辑访问文件

windows apache部署python_html_10

windows apache部署python_html_11

windows apache部署python_重启_12

测试的时候脚本不执行,而是直接暴露出来

windows apache部署python_html_13

解决方法:

编辑配置文件

windows apache部署python_重启_14

windows apache部署python_html_15

此时重启服务,文件内容不会暴露出来,但是访问仍然失败

windows apache部署python_php_16


这是因为安全上下问的问题

windows apache部署python_php_17


修改安全上下文和/var/www/cgi-bin/的安全上下文一致

windows apache部署python_重启_18


给文件添加可执行权限

windows apache部署python_重启_19


重启服务测试

windows apache部署python_html_20

python

1.将写好的python脚本放在/var/www/cgi-bin/目录下

windows apache部署python_html_21

python脚本内容如下:(功能:显示时间)

windows apache部署python_重启_22

2.用python命令调用脚本,不能执行,所以要给它添加执行权限

windows apache部署python_php_23

3.安装mod_wsgi

windows apache部署python_重启_24


windows apache部署python_html_25

4.进入子配置目录,编辑子配置文件webapp.conf

windows apache部署python_php_26


windows apache部署python_重启_27

5.在测试端主机添加相应的解析信息

windows apache部署python_重启_28

windows apache部署python_重启_29


6.重启服务

windows apache部署python_html_30

7.测试:在测试端浏览器中输入webapp.westos.com,会显示脚本执行结果

windows apache部署python_html_31