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

相关推荐
CryptoRzz10 分钟前
欧美(美股、加拿大股票、墨西哥股票)股票数据接口文档
java·服务器·开发语言·数据库·区块链
wanhengidc20 分钟前
巨椰云手机引领未来
运维·服务器·网络·游戏·智能手机
wanhengidc22 分钟前
云手机的真实体验感怎么样
运维·服务器·安全·游戏·智能手机
脏脏a28 分钟前
【Linux】Linux工具漫谈:yum 与 vim,高效操作的 “左膀右臂”
linux·运维·服务器
九河云1 小时前
TOS + 数字孪生:集装箱码头的智能进化密码
大数据·服务器·网络·数据库·数字化转型
代码or搬砖1 小时前
文件上传阿里云OSS以及本地图片服务器搭建
服务器·阿里云·云计算
悟能不能悟1 小时前
dcpatchscan.exe这是什么
运维·服务器
kyle~1 小时前
计算机系统---CPU的进程与线程处理
linux·服务器·c语言·c++·操作系统·计算机系统
wanhengidc1 小时前
云手机 流畅运行
运维·服务器·安全·游戏·智能手机
NiKo_W1 小时前
Linux 进程通信——基于责任链模式的消息队列
linux·服务器·消息队列·责任链模式·进程通信