小编这次要给大家分享的是使用python如何实现CGI环境搭建,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。

本文web服务器使用的为apache。
1. 安装apache
yum install -y httpd
2. 配置apache
修改apache配置文件/etc/httpd/conf/httpd.conf将下面一行的注释去掉,如果没有则添加:
LoadModule cgid_module modules/mod_cgid.so
cgi脚本文件的默认路径为/var/www/cgi-bin/
修改如下几处内容:
AllowOverride none
Require all denied
为:
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
去掉注释并添加.py
AddHandler cgi-script .cgi .py
3.重启apache
第一、启动、终止、重启
systemctl start httpd.service #启动
systemctl stop httpd.service #停止
systemctl restart httpd.service #重启
第二、设置开机启动/关闭
systemctl enable httpd.service #开机启动
systemctl disable httpd.service #开机不启动
4.检查httpd状态
systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 四 2018-12-27 10:05:27 CST; 6min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 4943 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─4943 /usr/sbin/httpd -DFOREGROUND
├─4946 /usr/libexec/nss_pcache 131074 off
├─4947 /usr/sbin/httpd -DFOREGROUND
├─4948 /usr/sbin/httpd -DFOREGROUND
├─4950 /usr/sbin/httpd -DFOREGROUND
├─4951 /usr/sbin/httpd -DFOREGROUND
├─4952 /usr/sbin/httpd -DFOREGROUND
└─4955 /usr/sbin/httpd -DFOREGROUND
12月 27 10:05:26 master systemd[1]: Starting The Apache HTTP Server...
12月 27 10:05:26 master httpd[4943]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.200. Set the ...is message
12月 27 10:05:27 master systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full. 文章标题:使用python如何实现CGI环境搭建-创新互联
本文来源:http://www.jxjierui.cn/article/dhogch.html


咨询
建站咨询
