zoukankan      html  css  js  c++  java
  • 部署并测试动态WSGI站点

                                                            部署并测试动态WSGI站点

    5.1问题

    本例要求为站点webapp0.example.com配置提供动态Web内容,要求如下:

    此虚拟主机侦听在端口8909

    测试网页从以下地址下载,不要作任何更改

    http://classroom/pub/materials/webinfo.wsgi

    从浏览器访问http://webapp0.example.com:8909可接收到动态生成的Web页面

    此站点必须能被example.com域内的所有系统访问

    5.2方案

    httpd增加对Python网页程序的支持,可以安装mod_wsgi模块。关于此模块的配置说明,建议参考软件包提供的readme文档。

    SELinux处于Enforcing模式时,若要开放非8081等常规Web端口,需要调整SELinux保护策略。

    5.3步骤

    实现此案例需要按照如下步骤进行。

    步骤一:部署动态网页文档

    1)创建网页目录

    [root@server0~]#mkdir /var/www/webapp0

    2)部署webinfo.wsgi网页程序

    [root@server0~]#cd /var/www/webapp0

    [root@server0webapp0]#wget http://classroom/pub/materials/webinfo.wsgi

    ....

    2016-11-27 01:52:26(16.0 MB/s)-webinfo.wsgisaved[397/397]

    [root@server0 webapp0]#cat webinfo.wsgi//检查下载文件

    #!/usr/bin/env python

    import time

    ....

    步骤二:配置新的虚拟主机http://webapp0.example.com8909/

    1)安装mod_wsgi模块软件包

    [root@server0~]#yum-y install mod_wsgi

    ....

    2)为新虚拟主机建立配置

    [root@server0~]#vim /etc/httpd/conf.d/02-webapp0.conf

    Listen 8909

    <VirtualHost*:8909>

    DocumentRoot/var/www/webapp0

    ServerName webapp0.example.com

    WSGIScriptAlias//var/www/webapp0/webinfo.wsgi

    </VirtualHost>

    3)调整SELinux策略,允许Web服务使用8909端口

    列出当前许可的Web端口:

    [root@server0~]#semanage port-l|grep^http_port

    http_port_t tcp 80,81,443,488,8008,8009,8443,9000

    添加新的Web端口:

    [root@server0~]#semanage port-a-t http_port_t-p tcp 8909

    [root@server0~]#

    确认配置结果:

    [root@server0~]#semanage port-l|grep^http_port

    http_port_t tcp 8909,80,81,443,488,8008,8009,8443,9000

    4)重启系统服务httpd

    [root@server0~]#systemctl restart httpd

    [root@server0~]#netstat-antpu|grep httpd//确认已监听8909端口

    tcp6 0 0:::443:::*LISTEN 2477/httpd

    tcp6 0 0:::8909:::*LISTEN 2477/httpd

    tcp6 0 0:::80:::*LISTEN 2477/httpd

    步骤三:测试动态网页效果

    使用elinksfirefox访问此动态站点http://webapp0.example.com:8909/

    多刷新访问几次,每次看到的是动态网页内容,内容并不固定。

    [root@desktop0~]#elinks -dump http://webapp0.example.com:8909/

    UNIX EPOCH time is now:1480184916.52//1次访问

    [root@desktop0~]#elinks -dump http://webapp0.example.com:8909/

    UNIX EPOCH time is now:1480184919.21//2次访问

    [root@desktop0~]#elinks -dump http://webapp0.example.com:8909/

    UNIX EPOCH time is now:1480184951.99//3次访问

  • 相关阅读:
    Hexo个人博客主题配置
    Hexo+Github/Gitee 搭建个人博客
    TCP/IP协议架构介绍(四):应用层
    TCP/IP协议架构介绍(三):传输层
    TCP/IP协议架构介绍(一):网络接口层
    Linux Bash编程
    TCP/IP协议架构介绍(二):网络层
    charles SSL证书安装
    Linux常用命令:性能命令
    简繁转换
  • 原文地址:https://www.cnblogs.com/qingbai/p/11940021.html
Copyright © 2011-2022 走看看