动态网页:使用网页脚本语言,比如php、JSP等,通过脚本将网站内容动态存储到数据库,用户访问网站是通过读取数据库来动态生成网页的方法。
WSGI(Web Server Gateway Interface)是一个统一的Python接口标准(PEP 3333),该标准描述了Python应用如何与Web服务器通信,多个Python应用之间如何级联以处理请求。
Apache HTTP服务器的mod_wsgi扩展模块,实现了Python WSGI标准
1)安装mod_wsgi
[root@server ~]# yum install mod_wsgi -y
2)简单的wsgi程序命名为myapp.wsgi
[root@servser ~]# vim /var/www/web/myapp.wsgi
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
3)配置虚拟主机
[root@server ~]# vim /etc/httpd/conf.d/vhosts.conf
添加以下内容:
LISTEN 888
<VirtualHost *:888>
WSGIScriptAlias /myapp(别名) /var/www/web/myapp.wsgi
</VirtualHost>
4)防护墙和selinux
[root@server ~]# firewall-cmd --permanent --add-port=888/tcp
success
[root@server~]# firewall-cmd --reload
success
[root@server httpd]# semanage port -a -t http_port_t -p tcp 888
5)重启服务测试
[root@server httpd]# systemctl restart httpd