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

相关推荐
Zach_yuan15 分钟前
深入浅出 JSONCpp
linux·服务器·网络·c++
马猴烧酒.32 分钟前
【面试八股|JAVA多线程】JAVA多线程常考面试题详解
java·服务器·数据库
熊延1 小时前
麒麟V10系统安装部署elasticsearch
linux·运维·服务器·elasticsearch·搜索引擎·全文检索
松涛和鸣3 小时前
72、IMX6ULL驱动实战:设备树(DTS/DTB)+ GPIO子系统+Platform总线
linux·服务器·arm开发·数据库·单片机
爱吃生蚝的于勒5 小时前
【Linux】进程信号之捕捉(三)
linux·运维·服务器·c语言·数据结构·c++·学习
The森5 小时前
Linux IO 模型纵深解析 01:从 Unix 传统到 Linux 内核的 IO 第一性原理
linux·服务器·c语言·经验分享·笔记·unix
期待のcode5 小时前
Redis的主从复制与集群
运维·服务器·redis
翼龙云_cloud5 小时前
腾讯云代理商: Linux 云服务器搭建 FTP 服务指南
linux·服务器·腾讯云
REDcker6 小时前
gRPC开发者快速入门
服务器·c++·后端·grpc
江湖有缘6 小时前
零基础入门:使用 Docker 快速部署 Organizr 个人主页
java·服务器·docker