基于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

相关推荐
不能跑的代码不是好代码7 小时前
Linux系统常用命令中文速查表
linux·运维·服务器
石一峰6997 小时前
深入理解 Linux 中断三层机制与 1-Wire 时序锁原理
linux·运维·服务器
无限码农8 小时前
Linux上通过cmake编译uchardet
linux·运维·服务器
ACP广源盛1392462567310 小时前
IX8024@ACP# 搭配此芯 AI 服务器 + 爱芯元智产品完整方案
大数据·运维·服务器·人工智能·分布式·嵌入式硬件
Hiyajo pray11 小时前
SDN 访问控制性能调优方法
服务器·网络·网络安全
huainingning13 小时前
交换机通过ftp下载文件或者传输文件到ftp服务器
运维·服务器·网络
小池先生14 小时前
Windows服务器如何备份
运维·服务器
运维大师15 小时前
【Linux运维极简教程】05-软件包管理
linux·运维·服务器
sramdram16 小时前
数字温度传感器应用于服务器系统热管理方案的优势
服务器·温度传感器·数字温度传感器
hehelm16 小时前
IO 多路复用 — Reactor
linux·服务器·网络·数据库·c++