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

相关推荐
island131419 小时前
【C++仿Muduo库#3】Server 服务器模块实现上
服务器·开发语言·c++
茉莉玫瑰花茶20 小时前
LangGraph 介绍
服务器·网络·数据库
mfxcyh21 小时前
如何把对象数据转化为数组
java·服务器·前端
2301_7807896621 小时前
云服务器数据会泄露吗?怎么保护云服务器的数据
运维·服务器·tcp/ip·网络安全
2301_7807896621 小时前
云服务器被黑能恢复吗?云服务器被黑的解决办法
运维·服务器·网络·安全·web安全
淘小白_TXB219621 小时前
头条百家采集改写发布软件用户使用手册
运维·服务器·头条采集·头条号采集·文章采集·头条采集软件
Web极客码1 天前
Akismet对WordPress防垃圾评论
服务器·搜索引擎·wordpress
渣渣灰95871 天前
解决VMware上终端窗口太小问题
运维·服务器·经验分享
谙弆悕博士1 天前
快速学C语言——第2章:编程规范与代码风格
服务器·c语言·开发语言·经验分享·程序人生·学习方法·业界资讯
线束线缆组件品替网1 天前
Amphenol ICC RJE1Y33610162401解析:工业网络线束为何越来越重要?
运维·服务器·网络·数码相机·智能路由器·电脑·智能音箱