web 關於http://localhost無法訪問的可能原因

web 關於http://localhost無法訪問的可能原因

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就可以了,下圖即為這種情況: