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

相关推荐
郝学胜-神的一滴1 小时前
Linux命名管道:创建与原理详解
linux·运维·服务器·开发语言·c++·程序人生·个人开发
宾有为1 小时前
【Linux】Linux 常用指令
linux·服务器·ssh
wanhengidc1 小时前
云手机性能如何?
运维·服务器·科技·智能手机·云计算
ajassi20001 小时前
开源 Linux 服务器与中间件(十三)FRP服务器、客户端安装和测试
linux·服务器·开源
Hellc0072 小时前
Docker部署BaGet私有NuGet服务器:从入门到备份恢复完整指南 二
服务器·docker·eureka
会飞的土拨鼠呀3 小时前
通过Linux进程id找到程序路径
linux·服务器·网络
wanhengidc5 小时前
云手机中的数据通常存储在哪里?
运维·服务器·安全·web安全·智能手机
凌寒116 小时前
Linux(Debain)安装Redis、数据迁移
linux·运维·服务器·redis
2501_921939266 小时前
11.25Nginx服务器和Wordpress服务器
运维·服务器·nginx
wanhengidc7 小时前
云手机中分布式存储的功能
运维·服务器·分布式·游戏·智能手机·云计算