2016-06-10 49 views
1

我想配置我的服務器以使用目錄/ home/imagenesDBD和我無法獲得它的工作,我搜索了很多,並且使每個示例我發現,但沒有什麼工作,我只是添加以下到httpd.conf文件Apache 403在根目錄之外配置目錄時出現禁止的錯誤

Alias "/imagenesDBD" "/home/imagenesDBD" 
<Directory "/home/imagenesDBD"> 
    Options FollowSymLinks 
    AllowOverride None 
    Order allow,deny 
    allow from all 
</Directory> 

目錄已經0777權限設置

Permission of execution

目錄的背景是

context directories

我期待得到這個URL工作http://mydomain/imagenesDBD

,並得到了以下錯誤

403 - 您沒有權限訪問/在此服務器imagenesDBD /上。

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

感謝您的幫助

+0

如果啓用了SELINUX,你必須改變的'上下文/ home/imagenesDBD'以匹配'/ var/www/html'的上下文。 SELINUX阻止'httpd'讀取具有錯誤上下文的目錄。 'ls -Z/home/imagenesDBD'和'ls -Z/var/www/html'將顯示這兩個目錄的上下文。請在你的問題中發佈上下文。 – alvits

+0

它應該是'ls -Zd/var/www/html'和'ls -Zd/home/imagenesDBD'。請發佈結果。發佈'getenforce'的結果。 – alvits

+0

我已經用上下文編輯了問題。感謝您的幫助,我現在應該做什麼? –

回答

2

/home/imagenesDBD類型的上下文是home_root_t

SELINUX將只允許類型上下文httpd_sys_content_t

您應該更改安全上下文的類型,它可以通過運行

$ sudo chcon -R -t httpd_sys_content_t /home/imagenesDBD 

這裏可以做,你可以發現chcon手動chcon

0

從文檔根目錄每次最多服務器根必須是可執行的,以便讓Apache穿越。

讓家和根可執行

sudo chmod +x/
sudo chmod +x /home 

另外,還要確保你確實有一個索引頁或Options Indexes

+0

我已經做了更改,錯誤仍在繼續,我要用它編輯問題,感謝您的幫助 –

+0

@OscarDavid您添加了選項索引,或者您是否嘗試去特定頁面,如http:/ /example.com/imagenesDBD/index.php –

+0

我使用hello world創建了一個文件,並得到了相同的錯誤:您無權訪問/imagenesDBD/index.php –