访问本机php文件无法解析_为什么我的本地环境不能解析子目录下的PHP文件

环境是

apache2.2

PHP5.4

在apache的安装目录下的htdosc是我的WEB根目录.

我在里面创建的项目不能解析PHP文件.会提示连接被重置!或网络已断开.在地址栏输入这个路径只能看到当前目录下的文件.

而根目录的index.php却能正常解析.

有时候自己就好了.很奇怪啊.

我觉得是httpd.conf的配置有问题.看了又找不出原因.我对apache的配置不是很懂.

请各位哥哥帮帮我.

回复讨论(解决方案)

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

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

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

TypesConfig conf/mime.types

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

Add……

你这里面有两条我配置里没有.我添加进去重启.没什么效果.应该不是块的问题.

你的什么系统

win7

早说啊,我上面那个是LInux下的Apache的配置文件,你看看这个和你的哪里不一样:

WAMP-windows_apache_mysql_php相关配置及搭建环境

不行啊. 常规配置我知道的.

根目录的.php文件就可以解析.到了子目录就不能解析了.如果子目录没有index.php那么浏览器就会列出所有子目录下的文件.如果有这个index.php,浏览器提示连接被重置,连接断开.

不是吧,按照#5文档修改的httpd.conf文件不会出现你这样的问题啊。是不是你哪里写重复了?或者没有写规范?和安装好的httpd.conf对比一下。

检查apache错误日志,看报什么错。

htdocs本来就是放静态文件的

动态文件,例如php放cgi-bin里

google关键字:Apache ScriptAlias

我是win7下的wamp环境,运行OK,如果需要,留个mail,我把我的发给你。

DefaultType text/plain# # 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

htdocs本来就是放静态文件的

动态文件,例如php放cgi-bin里

google关键字:Apache ScriptAlias

和什么目录没关系吧

我在里面创建的项目不能解析PHP文件.会提示连接被重置!或网络已断开.在地址栏输入这个路径只能看到当前目录下的文件.

而根目录的index.php却能正常解析.

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

搜索

Options Indexes FollowSymLinks

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

访问某个文件提示 连接被重置

那就查日志看看具体的错误是什么内容 .这种原因可能有很多,比如你的php出现错误 .打开 php.ini里的错误提示,设置浏览器的(IE的友好错误提示)...

多谢各位的解答.虽然一直没找出原因,但是也学了不少东西.

后来解决了.

解决方法很简单.我又重新下载了一个apache. 安装配置后,一切正常了.

我也遇到了这问题

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值