2013-03-25 202 views
17

今天我將我的圖像從一臺服務器遷移到另一臺服務器,並面臨一個奇怪的許可問題htaccess pcfg_openfile:無法檢查htaccess文件,確保它是可讀的,並且'/files/domain.com/public_html/images/'是可執行的

[Mon Mar 25 08:42:23.676315 2013] [core:crit] [pid 15182] (13)Permission denied: [client 24.14.2.22:48113] AH00529: /files/domain.com/public_html/images/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/files/domain.com/public_html/images/' is executable, referer: http://domain.com.com/file.php 

我已經試過:

chmod -R 777 root_dir 
    restorecon -r 
    disable selinux 
    Chown -R root:root root_dir 
+2

這是aufs中的一個錯誤,某些磁盤有錯誤的權限。 – teslasimus 2013-03-25 04:10:06

+5

除了根目錄本身外,您還需要所有父目錄都可以從Web服務器的用戶讀取。 – 2013-03-25 11:04:56

+0

chmod -R 777是一件非常危險的事情。它使每個目錄和文件世界都可寫和可執行。如果您想讓root_dir世界下的每個文件都可讀,並且root_dir世界可執行文件下的每個目錄(因此,如果名稱已知,所有人都可以訪問文件),則更安全的替代方案是find find_roles f -print0 | xargs -0 chmod o + r'; 'find root_dir -type d -print0 | xargs -0 chmod o + x' 如果您希望世界能夠在每個目錄上執行'ls'或'readdir',則替換o + rx。 – BertD 2015-07-08 22:29:39

回答

26

今天我遇到了這個問題。我轉的public_html從舊的驅動爲新的和chown這樣的:

chown -R owner:owner public_html 

這是子目錄和文件裏面的public_html是正確的,但的public_html的用戶必須是沒有人這樣Apache可以檢查它的內容,所以這解決我的問題:

chown owner:nobody public_html 

注:所有者是用戶(例如WEB1)

+4

Plesk的情況類似:'/ var/www/vhosts/example.com'文件夾必須由'user:psaserv'擁有,但其中的所有內容都由'user:psacln'擁有。 – 2013-11-27 14:52:15

0

當我檢查httpd/user-error_log,它給了

[Fri Jan 09 18:58:08 2015] [crit] [client 192.168.1.xxx] (13)Permission 
denied: /var/services/web/web-folder/.htaccess pcfg_openfile: unable to check 
htaccess file, ensure it is readable 

chmod 755沒有解決問題。下面的命令是適合我的。我使用HTTP,因爲它是在臺Synology DSM 5.1-5021 CD的/ var /服務/網絡 CHOWN HTTP使用的Apache用戶和組:HTTP web的文件夾

apache httpd.conf @ /etc/httpd/conf/httpd.conf 

更多有關新的變化細節 Apache/Webserver limitations in 5.0

1

TL; DR:

sudo chmod a+rx /var{,/services{,/web{,/web-folder}}}; 
find /var/services/web/web-folder -type d -exec sudo chmod a+rx {} +; 

您需要確定該目錄及其所有的父目錄,是可讀和可執行文件(可執行需要打開一個目錄)由網絡服務器。您可以通過使Web服務器用戶成爲擁有者並創建用戶權限(EG:chown apache <dir>; chmod u+rx <dir>;),或者通過將該組作爲Web服務器組成爲包含Web服務器用戶並將組權限設置爲(EG :chgrp apache <dir>; chmod g+rx <dir>;),或者通過將世界範圍設置爲(EG:chmod o+rx <dir>;)。

+0

在OS X上的根網站文件夾上運行'chmod a + x' – Anthony 2015-06-28 21:19:47

1

打開httpd.conf文件,並從所有改變拒絕從所有允許在.htaccess文件

以下行防止被

Web客戶查看的.htaccess和htpasswd文件。

<FileMatch "^\.ht"> 
    Order allow,dey 
    Allow from all 
</FileMatch> 

這個解決我的問題

1

我使用的Plesk瑪瑙和我同樣的錯誤信息,我只是改變了文件夾的權限,以775和它爲我工作。

3

我有同樣的問題。對我來說,這是SeLinux(CentOS 7)的一個問題。

它爲我的作品:

$ setsebool -P httpd_enable_homedirs true 
$ chcon -R -t httpd_sys_content_t /var/www/html/ 

請注意,您應該上述/var/www/html/更改爲相應的目錄。

相關問題