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

相关推荐
bcxwz66919 分钟前
linux 下常用变更-8
linux·运维·服务器
中科三方3 小时前
什么是权威解析服务器?权威解析服务器哪些作用?
服务器·git·github
七灵微3 小时前
【后端】单点登录
服务器·前端
xuanwojiuxin7 小时前
linux panic-propagation
linux·运维·服务器
achene_ql9 小时前
select、poll、epoll 与 Reactor 模式
linux·服务器·网络·c++
黎相思10 小时前
应用层自定义协议与序列化
运维·服务器·网络
jllllyuz11 小时前
如何为服务器生成TLS证书
运维·服务器·数据库
简朴-ocean12 小时前
如何删除linux空的文件夹
linux·运维·服务器
Code Warrior12 小时前
【Linux】Linux基础指令3
linux·服务器
光路科技13 小时前
TSN交换机正在重构工业网络,PROFINET和EtherCAT会被取代吗?
服务器·网络·重构