>  기사  >  백엔드 개발  >  为什么小弟我的本地环境不能解析子目录下的PHP文件

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

WBOY
WBOY원래의
2016-06-13 10:28:18797검색

为什么我的本地环境不能解析子目录下的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

------解决方案--------------------
检查apache错误日志,看报什么错。
------解决方案--------------------
htdocs本来就是放静态文件的
动态文件,例如php放cgi-bin里
google关键字:Apache ScriptAlias
------解决方案--------------------

PHP code
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><br><font color="#e78608">------解决方案--------------------</font><br>我在里面创建的项目不能解析PHP文件.会提示连接被重置!或网络已断开.在地址栏输入这个路径只能看到当前目录下的文件.<br>而根目录的index.php却能正常解析.<br><br>如果没有index.php索引文件,你直接打开目录的话 的确是显示文件目录结构的,如果有这个index.php文档,那么apache会先解析index.php文档.这个你可以在apache的配置文件修改  <br><br>搜索<br>Options Indexes FollowSymLinks<br><br>将Indexes 去掉 保存重启apache 即可.<br><br>访问某个文件提示 连接被重置<br>那就查日志看看具体的错误是什么内容 .这种原因可能有很多,比如你的php出现错误 .打开 php.ini里的错误提示,设置浏览器的(IE的友好错误提示)...<div class="clear">
                 
              
              
        
            </div>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.