久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

使用python實(shí)現(xiàn)CGI環(huán)境搭建過(guò)程解析

瀏覽:54日期:2022-07-27 10:19:41

本文web服務(wù)器使用的為apache。

1. 安裝apache

yum install -y httpd

2. 配置apache

修改apache配置文件/etc/httpd/conf/httpd.conf將下面一行的注釋去掉,如果沒(méi)有則添加:LoadModule cgid_module modules/mod_cgid.so

cgi腳本文件的默認(rèn)路徑為/var/www/cgi-bin/

修改如下幾處內(nèi)容:

<Directory />AllowOverride noneRequire all denied</Directory>

為:

<Directory '/var/www/cgi-bin'>AllowOverride NoneOptions +ExecCGIOrder allow,denyAllow from all</Directory>

去掉注釋并添加.py

AddHandler cgi-script .cgi .py

3.重啟apache

第一、啟動(dòng)、終止、重啟

systemctl start httpd.service #啟動(dòng)

systemctl stop httpd.service #停止

systemctl restart httpd.service #重啟

第二、設(shè)置開(kāi)機(jī)啟動(dòng)/關(guān)閉

systemctl enable httpd.service #開(kāi)機(jī)啟動(dòng)

systemctl disable httpd.service #開(kāi)機(jī)不啟動(dòng)

4.檢查httpd狀態(tài)

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 -DFOREGROUND12月 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 message12月 27 10:05:27 master systemd[1]: Started The Apache HTTP Server.Hint: Some lines were ellipsized, use -l to show in full.

5編寫(xiě)代碼

#!/usr/bin/python#coding=utf-8print 'Content-type:text/html'print #空行,告訴服務(wù)器結(jié)束頭部print ’<html>’print ’<head>’print ’<meta charset='utf-8'>’print ’<title>Hello Word - 我的第一個(gè)CGI程序!</title>’print ’</head>’print ’<body>’print ’<h2>嘿! 你最帥了 ~</h2>’print ’</body>’print ’</html>’

6前臺(tái)測(cè)試

使用python實(shí)現(xiàn)CGI環(huán)境搭建過(guò)程解析

OK 可以。

但是有一個(gè)問(wèn)題,這是引用的python2

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 台东市| 临夏县| 高要市| 梅河口市| 安顺市| 菏泽市| 贵州省| 华容县| 马关县| 望都县| 河南省| 名山县| 赞皇县| 馆陶县| 宣恩县| 民和| 江源县| 镇坪县| 新疆| 古交市| 宜春市| 措美县| 邵东县| 廉江市| 阿拉善盟| 铜陵市| 正阳县| 出国| 苍南县| 洛宁县| 囊谦县| 陆河县| 永靖县| 上犹县| 淄博市| 叙永县| 荆州市| 五莲县| 巢湖市| 曲水县| 曲阜市|