基于python的动态虚拟主机

1.安装python模块

dnf install python3-mod_wsgi -y

2.添加脚本

vim /var/www/cgi-bin/helloworld.wsgi

def application(environ, start_response):

status = '200 OK'

output = b'Hello World'

response_headers = [('Content-type', 'text/plain'),

('Content-Length', str(len(output)))]

start_response(status, response_headers)

return output

3.添加配置文件内容

配置文件:vim /etc/httpd/conf.d/vhost.conf

<virtualhost 192.168.233.139:80>

servername www.haha.com

WSGIScriptAlias / /var/www/cgi-bin/helloworld.wsgi

</virtualhost>

4.域名映射

vim /etc/hosts

192.168.233.139 www.haha.com

5.重启服务

systemctl restart httpd

6.访问内容

curl http://www.haha.com

相关推荐
无足鸟ICT7 小时前
【RHCA+】sosreport(收集诊断文档)
linux·运维·服务器
瑞雪兆丰年兮10 小时前
Linux零基础快速入门-第二章 Linux基础命令
linux·运维·服务器
光电笑映13 小时前
TCP 为什么可靠?从三次握手、滑动窗口到拥塞控制全面拆解(上)
运维·服务器·网络·udp
飞奔的瓜牛14 小时前
Linux 下使用 OpenSSL 生成自签名证书完整指南
运维·服务器·nginx
峥嵘life16 小时前
Android16 热点「网络共享」开关的设计与实现
服务器·网络·microsoft
张小姐的猫17 小时前
【基于 WebSocket 的多用户网页五子棋】—— 整合封装服务器模块设计实现1️⃣
服务器·websocket·网络协议
心之王者7161 天前
Linux 进程信号:从产生、阻塞到捕捉与子进程回收
linux·服务器·网络
manageengine1 天前
服务器 CPU 100% 怎么排查:8 条命令从现象定位到根因
运维·服务器·cpu
赤生云电竞1 天前
云游戏边缘节点部署:机房选址与网络拓扑优化实践 —— 从80ms时延预算看节点落位与Spine-Leaf组网
服务器·游戏·spine
爱吃香菜的初学者1 天前
二十五.Linux——epoll
linux·运维·服务器