I'm using vagrant to setup my centos 6.6 x86_64 virtual OS. I have installed apache and cakephp into it.
I have let Apache run as vagrant user and in vagrant group. And the vagrant's Vagrantfile has the line config.vm.synced_folder "./gym", "/var/www", mount_options: ["dmode=777", "fmode=777"].
After I run the index.php, the cakephp report the error:
PHP Warning: /var/www/gym_new/app/tmp/cache/persistent/ is not writable in /var/www/cake_2_6/Cake/Cache/Engine/FileEngine.php on line 385
PHP Warning: _cake_core_ cache was unable to write 'file_map' to File cache in /var/www/cake_2_6/Cake/Cache/Cache.php on line 328
So I open the FileEngine.php there is the code trigger error:
/**
* 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;
}
I think the permission has no problem so I create a brand new php just under webroot:
$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'];
}
My code runs perfect and the folders (tmp and cache) is created successful. But the same code in cakephp cannot go through. So is there anything I have missed? The cakephp file is outside of the webroot, dose this cause the problem ?