Cakephp无法创建tmp文件夹

时间:2015-10-22 13:56:40

标签: php cakephp permissions vagrant virtualbox

我正在使用vagrant来设置我的centos 6.6 x86_64虚拟操作系统。我已经安装了apache和cakephp。

我让Apache作为流浪者用户和流浪者群体运行。流浪者的Vagrantfileconfig.vm.synced_folder "./gym", "/var/www", mount_options: ["dmode=777", "fmode=777"]行。

运行index.php后,cakephp报告错误:

  

PHP警告:/ var / www / gym_new / app / tmp / cache / persistent /在第385行的/var/www/cake_2_6/Cake/Cache/Engine/FileEngine.php中无法写入

     

PHP警告:_cake_core_ cache无法在第328行的/var/www/cake_2_6/Cake/Cache/Cache.php中将'file_map'写入文件缓存

所以我打开FileEngine.php会出现代码触发错误:

/**
 * Determine is cache directory is writable
 *
 * @return bool
 */
    protected function _active() {
        $dir = new SplFileInfo($this->settings['path']);
        if (Configure::read('debug')) {
            $path = $dir->getPathname();
            if (!is_dir($path)) {
                mkdir($path, 0775, true);
            }
        }
        if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
            $this->_init = false;
            trigger_error(__d('cake_dev', '%s is not writable', $this->settings['path']), E_USER_WARNING);
            return false;
        }
        return true;
    }

我认为权限没有问题所以我在webroot下创建了一个全新的php:

$path = "/var/www/gym_new/app/tmp/cache/";
if(mkdir($path, 0775, true) && is_dir($path) && is_writable($path))
{
    echo "true";
}
else
{
    echo "false";
    $error = error_get_last();
    echo $error['message'];
}

我的代码运行完美,文件夹(tmp和缓存)创建成功。但是cakephp中的相同代码无法通过。那么我有什么遗漏的吗? cakephp文件在webroot之外,这会导致问题吗?

1 个答案:

答案 0 :(得分:2)

问题是if (Configure::read('debug'))

我发现我没有将调试设置为非零值,因此即使它们不存在,cakephp也不会创建文件夹。

相关问题