mac osx Forbidden You don't have permission to access / on this server解決方法

OpenSoucre發表於2015-01-12

(1)首先檢視*.conf 是否有讀寫許可權,如果沒有要將檔案賦予讀寫許可權,比如

sudo chmod 777 localhost.conf

(2)再檢視/Users/username/Sites/localhost/資料夾是否有index.html檔案,沒有的話,建立一個,預設是開啟index.html檔案

(3)最後檢視localhost配置檔案

對於OSX 10.9 Apache 2.2

<VirtualHost *:80>
    DocumentRoot "/Users/xx/Sites/localhost"
    ServerName localhost
    ErrorLog "/Users/xx/Sites/logs/localhost-error_log"
    CustomLog "/Users/xx/Sites/logs/localhost-access_log" common
    <Directory "/Users/xx/Sites/localhost">
            Order deny,allow
            Allow from all
    </Directory>
</VirtualHost>

對於OSX 10.10 Apache 2.4

<VirtualHost *:80>
    DocumentRoot "/Users/xx/Sites/localhost"
    ServerName localhost
    ErrorLog "/Users/xx/Sites/logs/localhost-error_log"
    CustomLog "/Users/xx/Sites/logs/localhost-access_log" common
    <Directory "/Users/xx/Sites/localhost">
            Require all granted    
    </Directory>
</VirtualHost>        

(4)最後重啟apache

 sudo apachectl restart

 

相關文章