配置UVDesk测试服务器时遇RuntimeException:无法写入cache目录
UVDesk配置报错:无法写入cache目录
错误信息
英文原文:Unable to write in the "cache" directory at Symfony\Component\HttpKernel\Kernel->buildContainer()
中文翻译:无法写入"cache"目录,错误触发于Symfony\Component\HttpKernel\Kernel类的buildContainer()方法
相关源码片段
protected function buildContainer() { foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } }
解决步骤
- 定位UVDesk项目的cache目录,默认路径为
var/cache - 检查目录权限:
- 测试环境快速修复:执行命令
chmod -R 777 var/cache - 生产环境安全配置:将目录所有者改为服务器运行用户(如www-data),执行
chown -R www-data:www-data var/cache,再设置权限为chmod -R 755 var/cache
- 测试环境快速修复:执行命令
- 若cache目录不存在,手动创建:
mkdir -p var/cache后再设置上述权限 - 重启PHP服务或刷新页面,验证问题是否解决
内容的提问来源于stack exchange,提问作者Prinsh Kumar
相关产品推荐
相关产品推荐

