Apache配置

在httpd.conf中查找DocumentRoot:

+ExecCGI 支持cgi

DocumentRoot  "F:\phpStud\PHPTutorial\WWW"
<Directory />
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>

让apache识别py文件为cgi程序:

AddHandler cgi-script .cgi .pl .py

指定目录下执行cgi程序

ScriptAlias /cgi-bin/ "F:/phpStud/PHPTutorial/Apache/cgi-bin/"

重启 apache, from.py 文件内容

#!D:\python\python.exe  #python 运行程序位置
#coding=utf-
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>Hello Word! 我是来自菜鸟教程的第一CGI程序</h2>')
print ('</body>')
print ('</html>')

运行文件存放位置

F:\phpStud\PHPTutorial\Apache\cgi-bin\from.py

浏览器访问地址:

http://localhost/cgi-bin/from.py

cgi 运行文件注意要点

第一:#! 前面不能有空格,后面紧跟解释程序;

第二,python等解释程序的目录是否正确;

第三,作为http协议的要求,一定要输出http headers;

第四,在存在http headers的前提下,一定要在headers后面打印一个空行,否则服务器会报错;

第五,把错误的程序在python的idle中执行一下,验证正确性;

最后,实在搞不定的情况下,查看apache的logs文件夹下的error.log文件,来确定问题。

相关文章:windows+phpstudy(apache) 以cgi方式支持python

Windows 配置Apache+CGI

windows+phpstudy(apache) 以cgi方式运行python的更多相关文章

  1. windows下更改Apache以fastcgi方式运行php

    Apache 默认 apache2handler 方式运行处理php. 下面说切换方法: 1.下载fastcgi模块,打开https://www.apachelounge.com/download/选 ...

  2. 在mac os下的Apache服务器的cgi中运行python

    我是搬运工.. Running Python Programs on the Mac OS X Apache Web Server The Mac OS X operating system incl ...

  3. 如何在Windows下开发Python:在cmd下运行Python脚本+如何使用Python Shell(command line模式和GUI模式)+如何使用Python IDE

    http://www.crifan.com/how_to_do_python_development_under_windows_environment/ 本文目的 希望对于,如何在Windows下, ...

  4. 在Apache中运行Python WSGI应用

    我们介绍如何使用Apache模块mod_wsgi来运行Python WSGI应用. 安装mod_wsgi 我们假设你已经有了Apache和Python环境,在Linux或者Mac上,那第一步自然是安装 ...

  5. Windows 下apache https配置(phpstudy)

    1.首先获取证书,https://www.pianyissl.com/  免费三个月的 或者 自己生成私钥.证书,然后应用到apache中. http://blog.sina.com.cn/s/blo ...

  6. Windows版本Apache+php的Xhprof应用

    [知识] {Apache} Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一. {PHP} ...

  7. 以OpenGL方式运行Unity

    Unity在Windows上默认以DirextX的方式运行,在MacOS和Linux上默认以OpenGl的方式运行, 如果希望在Windows上以OpenGL的方式运行可以在命令行中输入 -force ...

  8. linux运行python程序

    linux下有多种方式运行python:   1. 命令行执行: 建立一个*.py文档,在其中书写python代码.之后,在命令行执行: $ python   *.py 注意事项:1. 需要指明文件的 ...

  9. 【Python从入门到精通】(二)怎么运行Python呢?有哪些好的开发工具(PyCharm)

    您好,我是码农飞哥,感谢您阅读本文,欢迎一键三连哦. 这是Pyhon系列文章的第二篇,本文主要介绍如何运行Python程序以及安装PyCharm开发工具. 干货满满,建议收藏,需要用到时常看看. 小伙 ...

随机推荐

  1. java.io.IOException: Input is binary and unsupported

    十一月 16, 2019 11:49:47 上午 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() f ...

  2. SpringCloud基础知识

    什么是SpringCloud Spring Cloud是一系列框架的有序集合. 为什么用SpringCloud Spring Cloud涵盖面广,能够与Spring Framework.Spring ...

  3. CDH集群手动导入scm库

    一.手动导入 scm 库 背景:正常安装 cloudera-scm-server 时,安装 scm 库是通过脚本 /usr/share/cmf/schema/scm_prepare_database. ...

  4. [LeetCode] 750. Number Of Corner Rectangles 边角矩形的数量

    Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectang ...

  5. zabbix详解

    官网地址 https://www.zabbix.com/documentation/3.0/manual/config/items/itemtypes/zabbix_agent 使用率

  6. 【电商日志项目之五】数据分析-MR方式

    环境 hadoop-2.6.5 hbase-0.98.12.1-hadoop2 新增用户指标分析(1)用户分析模块 (2)浏览器分析模块 根据分析效果图,找出分析的维度:用户分析是指某个时间段内的数量 ...

  7. win10系统svn传图片卡死

        win10系统svn传图片或者文件有时候会卡死,原因是此种文件的默认打开程序与svn冲突了 svn提交的时候要打开图片,但是图片默认打开程序也要打开 所以冲突了 改下不冲突的默认打开程序就行了 ...

  8. python爬虫2

    学习任务 获取去哪儿网的出发地列表 获取旅游景点列表 获取景点产品列表 存储数据 1 获取出发地站点 (1)访问touch.qunar.com (2)按F12,单击自由行,在自由行页面点击搜索框 (3 ...

  9. dubbo问题集合

    背景:用于整理在开发过程中遇到的相关问题. Dubbo Server的时候出现“Will not attempt to authenticate using SASL (unknown error)” ...

  10. 在webstorm里使用git

    1,设置git 打开webstorm软件,找到file下面的settings(设置) 打开设置对话窗,找到version control的子级目录git,路径path输入git安装目录下bin目录里的 ...