2016-09-13 16 views
0

我有以下配置:致命錯誤:未捕獲Zend_Cache_Exception:cache_dir的 「......在/ var/page_cache」 是不是寫在.../zendframework1 /圖書館/ Zend公司/ Cache.php上線209

的CentOS使用mysql 5.7和php 7.0.10的VM x64

至於我的web服務器,我使用nginx和php-fpm。

從git倉庫所以我安裝的Magento,分支2.1,和我不斷收到此錯誤:

Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/usr/share/nginx/html/var/page_cache" is not writable in /usr/share/nginx/html/vendor/magento/zendframework1/library/Zend/Cache.php on line 209 

我試圖從nginx的改變Magento的/目錄的所有者遞歸到PHP- fpm,然後我嘗試給page_cache目錄提供權限,但似乎沒有發生,無論我嘗試什麼,都會出現同樣的錯誤。

我看到這個錯誤的唯一原因是因爲我在主索引文件中添加了語法ini_set('display_errors', 1);,否則我會看到一個銀行頁面。將magento更改爲開發者模式並沒有在頁面上顯示任何錯誤,也沒有做任何事情來顯示我正面臨的錯誤,也將文件local.xml.sample重命名爲local.xml。

回答

1

我會從緩存目錄及其父目錄上的ls -lh開始,以確保您對所做的每件事都擁有777權限。

如果做不到這一點 - 在Zend異常,你看到這裏發源:

# File: vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php 
public function setCacheDir($value, $trailingSeparator = true) 
{ 
    if (!is_dir($value)) { 
     Zend_Cache::throwException(sprintf('cache_dir "%s" must be a directory', $value)); 
    } 
    if (!is_writable($value)) { 
     Zend_Cache::throwException(sprintf('cache_dir "%s" is not writable', $value)); 
    } 
    if ($trailingSeparator) { 
     // add a trailing DIRECTORY_SEPARATOR if necessary 
     $value = rtrim(realpath($value), '\\/') . DIRECTORY_SEPARATOR; 
    } 
    $this->_options['cache_dir'] = $value; 
} 

所以,無論出於何種原因,當通過了緩存目錄PHP的is_writable函數返回false。結帳的is_writable's PHP manual entry並通過評論那裏可能的邊緣情況。從第一條評論的一個可能性

To Darek and F Dot: About group permissions, there is 
this note in the php.ini file: 

; By default, Safe Mode does a UID compare check when 
; opening files. If you want to relax this to a GID compare, 
; then turn on safe_mode_gid. 
safe_mode_gid = Off
+0

感謝您的回答,您提供的鏈接'is_writable'救了我:)我設法找出發生了什麼事情。我最終將所有者和組php-fpm:nginx提供給整個目錄,並解決了我所有的問題。 –

相關問題