神剑山庄资源网 Design By www.hcban.com
本文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/
修改如下几处内容:
<Directory />
AllowOverride none
Require all denied
</Directory>
为:
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
去掉注释并添加.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.
5编写代码
#!/usr/bin/python #coding=utf-8 print "Content-type:text/html" print #空行,告诉服务器结束头部 print '<html>' print '<head>' print '<meta charset="utf-8">' print '<title>Hello Word - 我的第一个CGI程序!</title>' print '</head>' print '<body>' print '<h2>嘿! 你最帅了 ~</h2>' print '</body>' print '</html>'
6前台测试
OK 可以。
但是有一个问题,这是引用的python2
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
标签:
python,CGI环境,搭建
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无使用python实现CGI环境搭建过程解析的评论...
更新日志
2024年09月30日
2024年09月30日
- 孙悦.1996-伙伴【正大国际】【WAV+CUE】
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】