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

相关推荐
稳联技术老娜2 小时前
DeviceNet主站怎么连接西门子PLC,Profinet网关配置手册(那智机器人)
服务器·网络·数据库
9分钟带帽2 小时前
linux_系统开机自动执行shell脚本
linux·服务器
消失在人海中3 小时前
oracle 数据库多表关联查询
服务器·数据库·oracle
嵌入式小能手4 小时前
飞凌嵌入式ElfBoard-进程间的通信之命名管道
linux·服务器·算法
荒--5 小时前
apt dpkg 命令详解
linux·服务器
LIZHUOLONG18 小时前
linux 设备初始化
linux·运维·服务器
遇印记8 小时前
软考知识点(局域网基础)
运维·服务器·局域网
難釋懷8 小时前
Nginx-CA 签名
服务器·nginx·ssl
ylscode8 小时前
Linux CIFSwitch 内核新漏洞允许攻击者获得 root 权限
linux·运维·服务器
TYKJ0239 小时前
租GPU服务器前必须确认的5个隐藏成本
服务器·后端·ai编程