无法写入元数据目录

Meta-Data directory cannot be written

我正在使用 Phalcon 和 MySQL。登录后我收到这样的错误,

Meta-Data directory cannot be written
#0 [internal function]: Phalcon\Mvc\Model\MetaData\Files->write('map-map\models\...', Array)
#1 [internal function]: Phalcon\Mvc\Model\MetaData->_initialize(Object(Map\Models\Users), NULL, NULL, NULL)
#2 [internal function]: Phalcon\Mvc\Model\MetaData->readColumnMapIndex(Object(Map\Models\Users), 1)
#3 [internal function]: Phalcon\Mvc\Model\MetaData->getReverseColumnMap(Object(Map\Models\Users))
#4 [internal function]: Phalcon\Mvc\Model::_invokeFinder('findFirstByUser...', Array)
#5 /var/www/html/app_map_system/app/library/Auth/Auth.php(27): Phalcon\Mvc\Model::__callStatic('findFirstByUser...', Array)
#6 /var/www/html/app_map_system/app/library/Auth/Auth.php(27): Map\Models\Users::findFirstByUsername('admin@admin.com')
#7 /var/www/html/app_map_system/app/controllers/IndexController.php(44): Map\Auth\Auth->check(Array)
#8 [internal function]: Map\Controllers\IndexController->loginAction()
#9 [internal function]: Phalcon\Dispatcher->callActionMethod(Object(Map\Controllers\IndexController), 'loginAction', Array)
#10 [internal function]: Phalcon\Dispatcher->dispatch()
#11 /var/www/html/app_map_system/public/index.php(41): Phalcon\Mvc\Application->handle()
#12 {main}

我已经使用此命令授予 www-data 以及我的用户对 /var/www/ 目录的访问权限,

sudo chown -R www-data:www-data /var/www/

但仍然出现相同的错误。任何遇到同样问题的人?任何帮助,将不胜感激。

我切换到 Ubuntu 时遇到了同样的问题。这是我解决它的方法。

首先,我意识到即使在 运行 在我的完整项目目录中启用 CHMod 之后,我总是会遇到元数据的写入错误。

用于配置模型元数据的部分 DI 代码:

$di -> set('modelsMetadata', function(){
    $metaData = new MetaDataAdapter([
        'metaDataDir'   => APP_PATH . '/cache/metaData/'
    ]);
    return $metaData;
});

确保文件夹存在。然后使用终端,我对 /app/cache/ 文件夹执行 cd 命令。在那里,运行:sudo chmod 755 metaData

希望这对您有所帮助...