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

相关推荐
知白守黑26715 分钟前
Linux磁盘阵列
linux·运维·服务器
TPBoreas3 小时前
Jenkins启动端口修改失败查找日志
运维·服务器·jenkins
正在努力的小河5 小时前
Linux设备树简介
linux·运维·服务器
小张快跑。5 小时前
Tomcat下载、安装及配置详细教程
java·服务器·tomcat
没有不重的名么6 小时前
Tmux Xftp及Xshell的服务器使用方法
服务器·人工智能·深度学习·机器学习·ssh
wdxylb6 小时前
云原生俱乐部-杂谈1
服务器·云原生
赏点剩饭7789 小时前
linux中的hostpath卷、nfs卷以及静态持久卷的区别
linux·运维·服务器
神鸟云9 小时前
DELL服务器 R系列 IPMI的配置
linux·运维·服务器·网络·边缘计算·pcdn
herderl10 小时前
**僵尸进程(Zombie Process)** 和**孤儿进程(Orphan Process)**
linux·运维·服务器·网络·网络协议
tomelrg10 小时前
多台服务器批量发布arcgisserver服务并缓存切片
服务器·python·arcgis