为什么我的本地环境不能解析子目录下的PHP文件

black_OX 2012-06-11 10:49:20
环境是
apache2.2
PHP5.4


在apache的安装目录下的htdosc是我的WEB根目录.
我在里面创建的项目不能解析PHP文件.会提示连接被重置!或网络已断开.在地址栏输入这个路径只能看到当前目录下的文件.
而根目录的index.php却能正常解析.

有时候自己就好了.很奇怪啊.
我觉得是httpd.conf的配置有问题.看了又找不出原因.我对apache的配置不是很懂.
请各位哥哥帮帮我.
...全文
591 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
haughtybow 2013-05-17
  • 打赏
  • 举报
回复
我也遇到了这问题
black_OX 2012-06-15
  • 打赏
  • 举报
回复
多谢各位的解答.虽然一直没找出原因,但是也学了不少东西.
后来解决了.
解决方法很简单.我又重新下载了一个apache. 安装配置后,一切正常了.
  • 打赏
  • 举报
回复
早说啊,我上面那个是LInux下的Apache的配置文件,你看看这个和你的哪里不一样:
WAMP-windows_apache_mysql_php相关配置及搭建环境
black_OX 2012-06-11
  • 打赏
  • 举报
回复
win7
paomoer 2012-06-11
  • 打赏
  • 举报
回复
你的什么系统
black_OX 2012-06-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

httpd.conf可解析的文件扩展名:

<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
Add……
[/Quote]

你这里面有两条我配置里没有.我添加进去重启.没什么效果.应该不是块的问题.
  • 打赏
  • 举报
回复
httpd.conf可解析的文件扩展名:

<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .phtml .vcgi
AddHandler type-map var
</IfModule>
黄袍披身 2012-06-11
  • 打赏
  • 举报
回复
我在里面创建的项目不能解析PHP文件.会提示连接被重置!或网络已断开.在地址栏输入这个路径只能看到当前目录下的文件.
而根目录的index.php却能正常解析.

如果没有index.php索引文件,你直接打开目录的话 的确是显示文件目录结构的,如果有这个index.php文档,那么apache会先解析index.php文档.这个你可以在apache的配置文件修改

搜索
Options Indexes FollowSymLinks

将Indexes 去掉 保存重启apache 即可.

访问某个文件提示 连接被重置
那就查日志看看具体的错误是什么内容 .这种原因可能有很多,比如你的php出现错误 .打开 php.ini里的错误提示,设置浏览器的(IE的友好错误提示)...
Liv2005 2012-06-11
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 的回复:]

引用 9 楼 的回复:

htdocs本来就是放静态文件的
动态文件,例如php放cgi-bin里
google关键字:Apache ScriptAlias


和什么目录没关系吧
[/Quote]

如果是apache的默认配置,就有关系,看一下apache默认ScriptAlias就知道了

当然如果LZ已经成功、正确修改了apache的配置,那我想就不会遇到顶楼所说的问题了....
black_OX 2012-06-11
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 的回复:]

htdocs本来就是放静态文件的
动态文件,例如php放cgi-bin里
google关键字:Apache ScriptAlias
[/Quote]

和什么目录没关系吧
tsucx 2012-06-11
  • 打赏
  • 举报
回复

DefaultType text/plain

<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
AddType application/x-httpd-php .php3

#
# 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>
tsucx 2012-06-11
  • 打赏
  • 举报
回复
我是win7下的wamp环境,运行OK,如果需要,留个mail,我把我的发给你。
Liv2005 2012-06-11
  • 打赏
  • 举报
回复
htdocs本来就是放静态文件的
动态文件,例如php放cgi-bin里
google关键字:Apache ScriptAlias
一起混吧 2012-06-11
  • 打赏
  • 举报
回复
检查apache错误日志,看报什么错。
  • 打赏
  • 举报
回复
不是吧,按照#5文档修改的httpd.conf文件不会出现你这样的问题啊。是不是你哪里写重复了?或者没有写规范?和安装好的httpd.conf对比一下。
black_OX 2012-06-11
  • 打赏
  • 举报
回复
不行啊. 常规配置我知道的.
根目录的.php文件就可以解析.到了子目录就不能解析了.如果子目录没有index.php那么浏览器就会列出所有子目录下的文件.如果有这个index.php,浏览器提示连接被重置,连接断开.

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧