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

相关推荐
dashizhi201513 分钟前
共享文件禁止拖动本地磁盘、共享文件禁止另存为、禁止打印共享文件、禁止复制共享文件的方法
运维·服务器·网络·安全·电脑
IMPYLH40 分钟前
Linux 的 nproc 命令
linux·运维·服务器·bash
万山寒3 小时前
linux日志查询,查找某个关键词后面的内容
linux·运维·服务器
小贾要学习3 小时前
【Linux】TCP网络通信编程
linux·服务器·网络·c++·网络协议·tcp/ip
Q3_SkyAsh3 小时前
【电子取证】——第三届“平航杯”电子数据取证竞赛服务器取证部分
服务器·电子取证
大白菜和MySQL3 小时前
apache服务器部署简记
运维·服务器·apache
渣渣馬4 小时前
rk3588s的firfly的linux的sdk版本
linux·运维·服务器
大数据新鸟5 小时前
NIO 三大核心组件
服务器·网络·nio
Hello World . .5 小时前
Linux驱动编程1:imxull上移植Linux系统
linux·运维·服务器
IMPYLH5 小时前
Linux 的 numfmt 命令
linux·运维·服务器·bash