免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3838 | 回复: 12
打印 上一主题 下一主题

有谁在看python how to program的吗?一起来学习. [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-09-02 17:14 |只看该作者 |倒序浏览
在学习python how to program的时候遇到了一下问题,想和同样也在学习的朋友一起来学习.共同进步.

论坛徽章:
0
2 [报告]
发表于 2008-09-02 17:22 |只看该作者
有问题就发把,也好学习下

论坛徽章:
0
3 [报告]
发表于 2008-09-02 17:53 |只看该作者
呵呵,是啊,有问题就发,不用一定找看那本书的人吧~

论坛徽章:
0
4 [报告]
发表于 2008-09-02 20:39 |只看该作者
当初看到CGI那章时,环境总搭不起来。

论坛徽章:
0
5 [报告]
发表于 2008-09-02 21:19 |只看该作者
我也是,我的运行环境是:windows xp + Python2.5 + Apache2.2.9 就是不知道怎么样配置Apache才能成功.第六章的6.3(电子档为117页)的例子fig06_03.py(从网上下载的程序)如果我用IIS作为web服务提供者(端口为8088,虚拟目录为d:\www),在浏览器上输入:http://localhost:8088/www/cgi-bin/fig06_03.py是可以正确显示结果,我的显示结果是:Tue Sep 02 20:52:59 2008.
但是如果我用Apache作为web服务提供者(端口为80,根目录已经改成d:\www)在浏览器上输入:http://localhost/cgi-bin/fig06_03.py ,则出现错误的提示如下)
************************************************************
Not Found

The requested URL /cgi-bin/fig06_03.py was not found on this server.
************************************************************
查看Apache的错误日志(C:\Program Files\Apache Software Foundation\Apache2.2\logs\error.log)如下:
************************************************************
[Tue Sep 02 20:25:24 2008] [notice] Child 1480: Starting thread to listen on port 80.
[Tue Sep 02 20:25:24 2008] [notice] Child 3456: All worker threads have exited.
[Tue Sep 02 20:25:24 2008] [notice] Child 3456: Child process is exiting
[Tue Sep 02 20:40:14 2008] [error] [client 127.0.0.1] File does not exist: D:/www/CFIDE
************************************************************

我的Apache配置(httpd.conf)如下(只写出修改的部分):

************************************************************
DocumentRoot "D:/www"

LoadModule python_module modules/mod_python.so

<Directory "D:/www">
    Options Indexes FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /cgi-bin/ "D:/www/cgi-bin/"

<Directory "D:/www/cgi-bin">
    AllowOverride None
    Options None
    SetHandler mod_python
    PythonHandler mod_python.publisher
    Order allow,deny
    Allow from all
</Directory>
************************************************************
apache服务正常.
另外我先了一个test.py程序,放在D:\www\cgi-bin.内容如下:
************************************************************
#!C:/Python25/python.exe
# Filename : test.py

def hello():
    return "hello world."

print "Hello world!"
************************************************************
如果我在浏览器上输入http://localhost/cgi-bin/test.py,显示:
************************************************************
Not Found

The requested URL /cgi-bin/fig06_03.py was not found on this server.
************************************************************
如果我在浏览器上输入http://localhost/cgi-bin/test.py/hello,显示则正常:
************************************************************
hello world.
************************************************************
我估计应该是apache的配置问题,但是我找过很多的资料,包括mod_python中文文档(链接地址:http://man.chinaunix.net/develop ... hon/mod_python.html).真是有焦头烂额的感觉.请帮助我.谢谢!

[ 本帖最后由 hansyang 于 2008-9-2 21:21 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2008-09-02 21:23 |只看该作者

回复 #4 lujx 的帖子

你现在搭起来了吗?是什么环境?windows or linux ?

论坛徽章:
0
7 [报告]
发表于 2008-09-03 09:01 |只看该作者

回复 #5 hansyang 的帖子

你是以CGI方式运行py,还是mod_python运行?

cgi方式很简单,只要按照CGI规范输出,在apache配置文件里加上.py这个后缀就行了

mod_python请参见我在版里发过一个配置文章

论坛徽章:
0
8 [报告]
发表于 2008-09-03 09:21 |只看该作者

回复 #7 xiaoyu9805119 的帖子

请问,什么是cgi方式,什么是mod_python的方式?

我的apache的配置是:

<Directory "D:/www/cgi-bin">
    AllowOverride None
    Options None
    SetHandler mod_python
    PythonHandler mod_python.publisher
    Order allow,deny
    Allow from all
</Directory>

我觉得我配置一个是mod_python的方式.
什么是cgi方式呢?

[ 本帖最后由 hansyang 于 2008-9-3 09:24 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2008-09-03 09:42 |只看该作者
mod_python配置可以看:http://bbs.chinaunix.net/thread-1198737-1-1.html

CGI配置你可以打开你的httpd.conf搜索下cgi-bin目录里面的配置,默认有.cgi你添加个.py

论坛徽章:
0
10 [报告]
发表于 2008-09-03 17:20 |只看该作者
我的配置
<Directory d:/apache/htdocs/timms.ext>
     AddHandler mod_python .prog
    PythonHandler dispatch
    PythonDebug on
</Directory>
浏览器这样访问http://10.60.33.177/timms.ext/fresh3.prog
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP