簡體   English   中英

PHP致命錯誤:帶有消息'cache_dir“/ tmp”的未捕獲異常'Zend_Cache_Exception'必須是目錄'

[英]PHP Fatal error: Uncaught exception 'Zend_Cache_Exception' with message 'cache_dir “/tmp” must be a directory'

我有關於zend cache_dir的問題。 我嘗試將我的網站從一台服務器轉移到另一台服務器,它可以工作。 但是,當我嘗試訪問該網站時,它顯示此錯誤:

PHP Fatal error:  Uncaught exception 'Zend_Cache_Exception' with message 'cache_dir "/tmp" must be a directory' in /home/aiesorgm/public_html/gcpi/library/Zend/Cache.php:209
Stack trace:

- #0 /home/aiesorgm/public_html/gcpi/library/Zend/Cache/Backend/File.php(178): Zend_Cache::throwException('cache_dir "/tmp...')
- #1 /home/aiesorgm/public_html/gcpi/library/Zend/Cache/Backend/File.php(129): Zend_Cache_Backend_File->setCacheDir('/tmp')
- #2 /home/aiesorgm/public_html/gcpi/library/Zend/Cache.php(153): Zend_Cache_Backend_File->__construct(Array)
- #3 /home/aiesorgm/public_html/gcpi/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('File', Array, false, false)
- #4 /home/aiesorgm/public_html/gcpi/application/Bootstrap.php(55): Zend_Cache::factory('Page', 'File', Array, Array)
- #5 /home/aiesorgm/public_html/gcpi/library/Zend/Application/Bootstrap/BootstrapAbstract.php(669): Bootstrap->_initCache()
- #6 /home/aiesorgm/public_html/gcpi/library/Zend/Application/Bootstrap/BootstrapAbstract.php(622): Zend_Application_Bootstrap_BootstrapAbstract-> in /home/aiesorgm/public_html/gcpi/library/Zend/Cache.php on line 209

我已經嘗試了所有可以從stackoverflow獲得的解決方案,但它仍然無效。 我還在公共文件夾中創建了tmp目錄,並將權限更改為777。

應用程序/ bootstrap.php中

protected function _initCache() {
    $info = Zend_Registry::get('info');

    $backendOptions = array(
        'cache_dir' => sys_get_temp_dir(),
        'hashed_directory_level' => 1,
        'file_name_prefix' => 'style',
        'automatic_cleaning_factor' => 1
    );
    $frontendOptions = array(
        'lifetime' => $info['cache']['lifetime'],
        'automatic_serialization' => true,
        'caching' => ($info['cache']['enabled'] == '1') ? true : false,
    );
    $cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
    Zend_Registry::set('cache', $cache);
}

/library/Zend/Cache/Backend/File.php

    protected $_options = array(
    'cache_dir' => null,
    'file_locking' => true,
    'read_control' => true,
    'read_control_type' => 'crc32',
    'hashed_directory_level' => 0,
    'hashed_directory_perm' => 0700,
    'file_name_prefix' => 'zend_cache',
    'cache_file_perm' => 0600,
    'metadatas_array_max_size' => 100
);

文件夾結構

應用

  • 配置
  • 調節器
  • 形成
  • 布局
  • 楷模
  • 視圖

文檔

圖書館

上市

  • CSS
  • JS
  • 圖片
  • TMP
  • 的.htaccess
  • 的index.php

10Q你的閱讀時間。

/tmp是完整路徑,因此ZF不會嘗試寫入公用文件夾中名為tmp的文件夾,它正在嘗試寫入文件系統根目錄下的系統臨時文件夾。

我建議改為設置項目特定的緩存文件夾:

$backendOptions = array(
    'cache_dir' => APPLICATION_PATH.'/../data/cache',
    'hashed_directory_level' => 1,
    'file_name_prefix' => 'style',
    'automatic_cleaning_factor' => 1
);

然后在項目中創建一個名為data的文件夾,並在其中創建一個cache文件夾,並使其可寫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM