配置动态web服务(wsgi)
实现动态web内容,虚拟主机监听在端口8909,客户端访问时,能接受到生成的web页面
第一步:Python脚本(放在网页根目录下)
[root@catyuan ~]# vim /var/www/html/webinfo.wsgi
!/usr/bin/env python
import time
def application (environ, start_response):
a = time.ctime(time.time())
response_body = 'This Dynamic WSGI Page Was Generated at: \n%s\n'%a
status = '200 OK'
output="hello world"
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', '1'),
('Content-Length',str(len(response_body)))]
start_response(status, response_headers)
return [response_body]
第二步:安装wsgi模块
[root@catyuan ~]# yum install mod_wsgi -y
第三步:更改配置文件
[root@catyuan ~]# vim /etc/httpd/conf.d/host.conf
listen 8909
<virtualhost 172.24.8.2:8909>
WSGIScriptAlias / /var/www/html/webinfo.wsgi
<directory /var/www/html>
require all granted
第四步:重启
[root@catyuan ~]# systemctl restart httpd
第五步:测试
[root@catyuan ~]# curl -k http://172.24.8.2:8909
hello world