web 关于http://localhost无法访问的可能原因

本文详细介绍了如何解决Apache服务器中的多个配置问题,包括修改目录索引、启用PHP支持、解析.htaccess文件以及设置文件权限,确保服务器正常运行。

1. /private/var/log/apache2/error_log中错误信息:

[Thu Feb 04 22:30:52.580099 2016] [autoindex:error] [pid 253] [client ::1:49599] AH01276: Cannot serve directory /Library/WebServer/Documents/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

修改方法:

<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>


2.访问localhost只是把index.php的文本显示出来

修改方法:

在httpd.conf中解开注释:LoadModule php5_module libexec/apache2/libphp5.so

在httpd.conf中加入 AddType application/x-httpd-php .php


3.error_log中错误信息:

[Fri Feb 05 08:15:45.658323 2016] [core:alert] [pid 1292] [client ::1:51682] /Library/WebServer/Documents/pinpoint/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

修改方法:

在httpd.conf中解开注释:LoadModule rewrite_module libexec/apache2/mod_rewrite.so



4.Forbidden You don't have permission to access / on this server.

[Fri Feb 05 09:07:17.407615 2016] [core:error] [pid 1940] (13)Permission denied: [client ::1:52605] AH00035: access to / denied (filesystem path '/Users/worldzhy/Documents/InceptionPad') because search permissions are missing on a component of the path

修改方法:不但目的路径的权限要设置为755,目的路径向上追溯的每一级父路径都要设置权限为755.

这篇blog写得很认真 http://blog.163.com/lgh_2002/blog/static/4401752620145110950807/


5.如果有项目本身需要write权限,只要把具体的子路径权限改为777就可以了,下图即为这种情况:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值