http_动态网站

动态网站

服务端的原始网页 ≠ 浏览器访问到的网页
由Web服务软件接受请求,动态程序转后端模块处理。
PHP网页、Python网页、JSP网页
----------------------------------------------------------------------------------
部署动态WSGI站点

为站点 webapp0.example.com 配置提供动态Web内容,要求如下:
1)此虚拟主机侦听端口8909
2)测试网页从以下地址下载,不要作任何更改http://classroom/pub/materials/webinfo.wsgi
3)从浏览器访问 http://webapp0.example.com:8909 可接收到动态生成的 Web 页面。


1,下载Python网页文件,到站点webapp0.example.com网页根目录。

cat /etc/httpd/conf.d/nsd.conf #查看网页文件路径
cd /var/www/nsd02 #wget默认下载在当前目录
wget http://classroom.example.com/pub/materials/webinfo.wsgi

2,网页跳转(方便用户的访问)

配置字段格式: Alias 网络路径 实际本地路径

vim /etc/httpd/conf.d/nsd.conf
<VirtualHost *:80>
ServerName webapp0.example.com
DocumentRoot /var/www/nsd02
Alias / /var/www/nsd02/webinfo.wsgi
#当客户端访问网页文件根目录时,跳转到webinfo.wsgi页面

</VirtualHost>

重起httpd

3,装包mod_wsgi,专门翻译Python代码页面
yum -y install mod_wsgi
vim /etc/httpd/conf.d/nsd.conf
只修改这一行WsgiScriptAlias / /var/www/nsd02/webinfo.wsgi
#开头加入字母 WsgiScript

扫描二维码关注公众号,回复: 6051077 查看本文章

重起httpd

虚拟机desktop0验证:firefox webapp0.example.com

网页内容显示:显示当前系统的Unix时间戳
Unix时间戳:自1970-1-1 0:0:0 到当前系统时间经历的秒数

4.此虚拟主机侦听端口8909
vim /etc/httpd/conf.d/nsd.conf
Listen 8909
<VirtualHost *:8909>
ServerName webapp0.example.com
DocumentRoot /var/www/nsd02
WsgiScriptAlias / /var/www/nsd02/webinfo.wsgi
</VirtualHost>

5,SELinux非默认端口的开放
semanage port -l | grep http #列出所有端口
semanage port -a -t http_port_t -p tcp 8909
# -a:添加 -t:类型 -p:协议

重启httpd

虚拟机desktop0验证:firefox webapp0.example.com:8909
---------------------------------------------------------------------------------
动态Web 思路

环境:2台虚拟机
1,防火墙设为trusted
2,yum清缓存,列仓库

服务端:
1.装包mod_wsgi,翻译python代码
2.下载python到网页根目录
3.写配置文件(监听端口,翻译代码,网页跳转)
Listen 8909
<VirtualHost *:8909>
WsgiScriptAlias 网络路径 实际本地路径
4.修改SELinux端口
semanage port -l | grep http #复制http_port_t
semanage port -a -t http_port_t -p tcp 8909
5.重起httpd服务

客户端:访问端口8909
################################################
动态Web
1.下载或书写一个python
2.进行网页的跳转 Alias 网络路径 实际本地路径
3.安装mod_wsgi软件支持翻译python代码
4.书写配置WsgiScriptAlias 网络路径 实际本地路径
5.重起httpd服务
6.书写配置文件
Listen 8909
<VirtualHost *:8909>
7.修改SELinux端口
8.重起httpd服务
----------------------------------------------------------------------------------
虚拟web主机匹配优先级:由上到下,匹配及停止
端口的优先级要大于域名
----------------------------------------------------------------------------------
服务端提供资源:
1)新建目录
2)修改配置文件
3)修改配置文件,添加访问控制
4)重起httpd服务

客户端访问资源:
防火墙
SELinux
服务本身的限制
本地目录的限制

猜你喜欢

转载自www.cnblogs.com/summer2/p/10787856.html