CGI--common gateway interface 通用网关接口的意思,本文通过python的CGI来整体了解下CGI的配置和使用

CGI配置(Mac版)

  • 安装前提要装好apache,python等必要软件,本次只针对CGI的配置
进入apache2目录
/etc/apache2
编辑httpd.conf
vi httpd.conf
  • 取消注释LoadModule cgi_module libexec/apache2/mod_cgi.so,截图如下

  • 设置/Library/WebServer/CGI-Executables目录的权限

<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
  • 同时注释调
#<Directory />
# AllowOverride none
# Require all denied
#</Directory>
  • 取消注释AddHandler cgi-script .cgi,同时在末尾加上.py

  • 重启apache2

sudo  apachectl restart

添加CGI python文件测试

  • 进入刚才设置的目录/Library/WebServer/CGI-Executables

    建test.py,并授权chmod 777 test.py
#!/usr/bin/python
# -*- coding: UTF-8 -*- print "Content-type:text/html"
print
print '<html>'
print '<head>'
print '<meta charset="utf-8">'
print '<title>Hello World - 我的第一个 CGI 程序!</title>'
print '</head>'
print '<body>'
print '<h2>Hello World! </h2>'
print '</body>'
print '</html>'
  • 通过浏览器访问http://localhost/cgi-bin/test.py

整个python CGI配置流程结束

Pyhton配置CGI的更多相关文章

  1. 软件:IIS上配置CGI

    本文的内容是:在Windows7中的IIS6.1中配置CGI功能. 我先讲步骤,步骤全用图来说明,以方便技术还是不熟练的朋友,以下是在Windows7系统来完成的. 目录 一.安装IIS步骤: 0X0 ...

  2. TOMCAT 安装教程 & 配置CGI & c语言exe

    TOMCAT安装 参考原文网址:百度经验http://jingyan.baidu.com/article/154b4631aad2bb28ca8f4191.html 1.下载安装JDK 网址:http ...

  3. ubuntu 安装apache2并配置cgi,搭建mimetex转化公式图片的服务

    一.Apache的安装 在终端输入: sudo apt-get install apache2 二.启动.停止Apache服务 Apache的启动和停止文件是:/etc/init.d/apache2 ...

  4. ubuntu14 下配置cgi

    1.安装apache2 sudo apt-get install apache2 2.配置apache2 vim /etc/apache2/sites-enabled/ 000-default.con ...

  5. 用pyhton配置LVS_DR模式

    import paramiko vip = '192.168.42.250' ds = '192.168.42.8' rs1 = '192.168.42.9' rs2 = '192.168.42.10 ...

  6. Tomcat 下配置OpenLayers proxy.cgi代理

    摘要:在OpenLayers访问WFS服务时,会遇到跨域的问题而导致服务无法访问.此时,需要在应用程序中设置代理,通过代理进行访问.本文介绍在tomcat进行proxy.cgi文件配置,以及在调用代理 ...

  7. C、Shell、Perl基于Tomcat开发CGI程序环境配置

    基于Tomcat7.0版本号配置CGI开发环境,步聚例如以下: 以我的Tomcat7安装文件夹为例:TOMCA_HOME = /Users/yangxin/Documents/devToos/java ...

  8. ubuntu配置apache和cgi

    ubuntu配置apache和cgi . 更新源并进行安装,否则后面的下载可能会不成功. sudo apt-get update sudo apt-get upgrade . 安装apache2服务 ...

  9. Ubuntu下配置Apache以及搭载CGI

    在Windows下自己下载应用过Apache,在Linux下也用到了服务器,就选择了Apache.Apache的安装在Ubuntu下异常简单. 1. 上网下载自动包安装 sudo apt-get in ...

随机推荐

  1. mac osx 升级到10.10 软件无法打开的问题

    osx升级到10.9.5 和10.10后,很多软件出现无法打开的问题, This patch seems to be corrupted.Please make sure you get your p ...

  2. MySql5.7.* 多实例安装部署

    参考文献: http://blog.csdn.net/tornadojava/article/details/53318773 http://blog.csdn.net/u013948858/arti ...

  3. ZT 9种排序

    9种排序 2012-09-19 14:58 66人阅读 评论(0) 收藏 编辑 删除 algorithmfpfilemergeintegerfloat [cpp] view plaincopy #in ...

  4. taskset

    常常感觉系统资源不够用,一台机子上跑了不下3个比较重要的服务,但是每天我们还要在上面进行个备份压缩等处理,网络长时间传输,这在就很影响本就不够用的系统资源: 这个时候我们就可以把一些不太重要的比如co ...

  5. 判断是否是微信浏览器JavaScript代码

    function isWeiXin(){     var ua = window.navigator.userAgent.toLowerCase();     if(ua.match(/MicroMe ...

  6. Yarn遭到挖矿病毒攻击

    测试环境在阿里云上暴露出了公网端口,前一段时间CDH集群原本是开启了Kerberos认证,但是因为大家反映使用麻烦,所以就又关闭了Kerberos. 最近几天大家普遍反映测试环境上hive和hdfs ...

  7. UVa 1393 - Highways(数论)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. BZOJ1076:[SCOI2008]奖励关(状压DP,期望)

    Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物, 每次你都可以选择吃或者不吃(必须在抛出下一个宝物之前做出选择,且现在决定不吃的 ...

  9. P3558 [POI2013]BAJ-Bytecomputer

    题目描述 A sequence of integers is given. The bytecomputer is a device that allows the following operati ...

  10. oracle查询指定月份数据

    SELECT * FROM [表名]       where  to_number(to_char([表中日期字段],'mm')) = [要查找的月份]