免费注册 查看新帖 |

Chinaunix

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

[Web] 谁见过这个问题?-- apache将配置文件的一段打印在index.php上 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-05 18:07 |只看该作者 |倒序浏览
20可用积分
操作系统版本:SUSE9
apache版本 :2.2.6
php版本:5.2.4

打开首页面的时候,在页面的上方显示这样一段信息:
# # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # #AddHandler cgi-script .cgi # For type maps (negotiated resources): #AddHandler type-map var # # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # #AddType te@?  PHP/5.2.4 X-Powered-By: PHP/5.2.4 Content-Length: 4624 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html

在信息的下面才是登陆页面,但页面上的图片都显示不出来,重启apache之后问题就消失了。
上面那段信息是apache配置文件httpd.conf中的一段,他包含在<IfModule mime_module>和</IfModule>之间,我将这一段帖出来,请大奖帮我分析一下:
<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

这段信息中包含的有效内容就只有
   TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
这四项,而页面上方打印出来的那段信息就在AddType application/x-httpd-php .php的下面。有没有人遇到过这种情况呢?

论坛徽章:
0
2 [报告]
发表于 2008-08-05 20:36 |只看该作者
顶上去,麻烦大家给点想法或方向

论坛徽章:
0
3 [报告]
发表于 2008-08-05 22:09 |只看该作者
既然重启就好了,应该是apache加载配置文件出了点问题吧.偶然性小概率事件总有的.

论坛徽章:
0
4 [报告]
发表于 2008-08-06 09:17 |只看该作者
原帖由 xi2008wang 于 2008-8-5 22:09 发表
既然重启就好了,应该是apache加载配置文件出了点问题吧.偶然性小概率事件总有的.




不对,我已经发现两例了,难道是我rp太差了?!
有没有可能是index.php文件内容的问题导致这个现象的出现呢?

论坛徽章:
0
5 [报告]
发表于 2008-08-06 10:45 |只看该作者
原帖由 wllhc 于 2008-8-6 09:17 发表




不对,我已经发现两例了,难道是我rp太差了?!
有没有可能是index.php文件内容的问题导致这个现象的出现呢?

那简单的php测试页面有没有发生这样的事呢?又或者你下的apache包不好?

论坛徽章:
0
6 [报告]
发表于 2008-08-06 11:43 |只看该作者
我自己的分析,初步判断问题是apache在解析php的addType的时候出现了异常,把下面的注释送到标准输出了。
报错的那段信息是apache配置文件httpd.conf中的一段,他包含在<IfModule mime_module>和</IfModule>之间,apache2支持了DSO模块访问方式,注意到index.php页面上方的报错是出现在<IfModule mime_module>和</IfModule>之间,并且存在于AddType application/x-httpd-php .php的下面,这样可以推断,很可能是因为apache没有及时的识别出.php格式的文件,IfModule mime_module的意思是,如果mime_module这个模块被安装的话,才进行里面的动作。也就说在apache在启动或加载默认首页面时,需要一个特殊的处理,但由于页面上没有需要apache调用mime_module的地方,导致httpd-php这个type没有提前被加载,使得php解释器无法识别页面的格式。由于php是以LoadModule 的方式来加载到apache的,所以application/x-httpd-php .php应该在php的module加载的时候就被定义。
    我觉得可以通过将AddType application/x-httpd-php .php这条配置语句放到LoadModule php5_module       modules/libphp5.so 的下面来解决这个问题。

论坛徽章:
0
7 [报告]
发表于 2008-08-06 17:44 |只看该作者
有几点疑问:

原帖由 wllhc 于 2008-8-6 11:43 发表
我自己的分析,初步判断问题是apache在解析php的addType的时候出现了异常,把下面的注释送到标准输出了。

应该是送到socket里去了吧,到标准输出都是在服务器的屏幕上了

原帖由 wllhc 于 2008-8-6 11:43 发表
报错的那段信息是apache配置文件httpd.conf中的一段,他包含在<IfModule mime_module>和</IfModule>之间,apache2支持了DSO模块访问方式,注意到index.php页面上方的报错是出现在<IfModule mime_module>和</IfModule>之间,并且存在于AddType application/x-httpd-php .php的下面,这样可以推断,很可能是因为apache没有及时的识别出.php格式的文件,IfModule mime_module的意思是,如果mime_module这个模块被安装的话,才进行里面的动作。也就说在apache在启动或加载默认首页面时,需要一个特殊的处理,但由于页面上没有需要apache调用mime_module的地方,导致httpd-php这个type没有提前被加载,使得php解释器无法识别页面的格式。由于php是以LoadModule 的方式来加载到apache的,所以application/x-httpd-php .php应该在php的module加载的时候就被定义。
    我觉得可以通过将AddType application/x-httpd-php .php这条配置语句放到LoadModule php5_module       modules/libphp5.so 的下面来解决这个问题。

AddType 一般在 LoadModule之后啊
还有httpd加载配置文件是在它启动时那一刻加载,加载完了甚至都可以把httpd.conf删了.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP