0

我有工作的 CakePHP2.5.dev应用程序,我cache在 CakePHP 中通过

Configure::write('debug', 2);
Configure::write("Cache.disable", true);

app/Config/core.php

不幸的是,我必须将此应用程序部署到无法写入app/tmp目录的服务器上。

我检查了 StackOverflow 上的答案,如何禁用缓存和上面的行app/Config/core.php,甚至注释掉负责缓存的其余行,即

/**
 * Configure the cache used for general framework caching. Path information,
 * object listings, and translation cache files are stored with this configuration.
 */
//Cache::config('_cake_core_', array(
//  'engine' => $engine,
//  'prefix' => $prefix . 'cake_core_',
//  'path' => CACHE . 'persistent' . DS,
//  'serialize' => ($engine === 'File'),
//  'duration' => $duration
//));

/**
 * Configure the cache for model and datasource caches. This cache configuration
 * is used to store schema descriptions, and table listings in connections.
 */
//Cache::config('_cake_model_', array(
//  'engine' => $engine,
//  'prefix' => $prefix . 'cake_model_',
//  'path' => CACHE . 'models' . DS,
//  'serialize' => ($engine === 'File'),
//  'duration' => $duration
//));

但是当我在生产服务器上运行我的应用程序时,我得到了一个异常。

Warning: /home/kowalski_m/public_html/projekt2/app/tmp/cache/persistent/ is not writable in /home/kowalski_m/public_html/projekt2/lib/Cake/Cache/Engine/FileEngine.php on line 384

Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /home/kowalski_m/public_html/projekt2/lib/Cake/Cache/Cache.php:181 Stack trace: #0 /home/kowalski_m/public_html/projekt2/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_') #1 /home/kowalski_m/public_html/projekt2/app/Config/core.php(376): Cache::config('_cake_core_', Array) #2 /home/kowalski_m/public_html/projekt2/lib/Cake/Core/Configure.php(72): include('/home/kowalski_...') #3 /home/kowalski_m/public_html/projekt2/lib/Cake/bootstrap.php(175): Configure::bootstrap(true) #4 /home/kowalski_m/public_html/projekt2/app/webroot/index.php(94): include('/home/kowalski_...') #5 /home/kowalski_m/public_html/projekt2/index.php(41): require('/home/kowalski_...') #6 {main} thrown in /home/kowalski_m/public_html/projekt2/lib/Cake/Cache/Cache.php on line 181

在此处输入图像描述

所以看起来缓存仍然有效。

我无法在此服务器中获得此目录的写入规则。我无权访问root。

如何完全禁用缓存并将 CakePHP 设置为不写入任何内容/app/tmp

4

1 回答 1

1

你的服务器上安装了 APC 吗?

如果是这样,那么您可以使用它来缓存核心。无论如何,这比访问文件系统要快。

您将需要配置 cake_core 的那些行,请务必设置

$engine = 'Apc';

在缓存配置行之上。

如果在共享服务器上使用 APC,正确设置前缀很重要,我使用以下配置,它适用于安装了多个蛋糕应用程序的共享主机:

Cache::config(
    '_cake_core_',
    array(
        'engine' => $engine,
        'prefix' => $prefix . 'cake_core_' . Inflector::slug(ROOT),
        'path' => CACHE . 'persistent' . DS,
        'serialize' => ($engine === 'File'),
        'duration' => $duration
    )
);

或者:

您不需要 root 访问权限来设置该文件夹的权限,您所需要的只是 FTP 访问权限。您可以使用 FTP 将 app/tmp/* 的权限设置为 777,这是我对我使用的其他一些临时文件夹所做的。

于 2014-02-18T04:41:52.013 回答