【发布时间】:2016-11-13 20:25:22
【问题描述】:
我想继续一个好久没碰过的项目,执行时遇到了这个错误php bin/console doctrine:generate:entites SalonBundle(它来自shell,所以它使用PHP CLI)
Generating entities for bundle "SalonBundle"
> backing up Salon.php to Salon.php~
> generating SalonBundle\Entity\Salon
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: chmod(): Operation not permitted
doctrine:generate:entities [--path PATH] [--no-backup] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <name>
首先,我不确定为什么 Symfony 尝试使用 chmod
所有文件归root:www-data所有
文件权限为rw-rw-r--
我的用户在组www-data
上传、创建文件、复制、移动等工作正常
权限是通过运行以下命令的脚本设置的$targetDir是作为参数传递给脚本的路径。
chown -R root:www-data $targerDir
find $targerDir -type d -exec chmod ug+rwx "{}" \;
find $targerDir -type f -exec chmod ug+rw "{}" \;
find $targerDir -type d -exec chmod g+s "{}" \;
find $targerDir -type d -exec setfacl -m g:www-data:rwx,d:g:www-data:rwx "{}" \;
find $targerDir -type f -exec setfacl -m g:www-data:rw- "{}" \;
刚刚按照某人的建议将 -vvv 添加到命令行并得到了这个:
Exception trace:
() at /var/www/3DH/salon/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php:392
Symfony\Component\Debug\ErrorHandler->handleError() at n/a:n/a
chmod() at /var/www/3DH/salon/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php:392
Doctrine\ORM\Tools\EntityGenerator->writeEntityClass() at /var/www/3DH/salon/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php:347
Doctrine\ORM\Tools\EntityGenerator->generate() at /var/www/3DH/salon/vendor/doctrine/doctrine-bundle/Command/GenerateEntitiesDoctrineCommand.php:133
Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() at /var/www/3DH/salon/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:256
Symfony\Component\Console\Command\Command->run() at /var/www/3DH/salon/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:837
Symfony\Component\Console\Application->doRunCommand() at /var/www/3DH/salon/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:187
Symfony\Component\Console\Application->doRun() at /var/www/3DH/salon/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/3DH/salon/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:118
Symfony\Component\Console\Application->run() at /var/www/3DH/salon/bin/console:27
This topic 不提供解决方案
This solution 不适用于我,因为我不使用 vagrant(未安装)
【问题讨论】:
-
为什么文件应该归root所有?
-
谁是文件所有者无关紧要,因为编辑文件的是组。我以前从未遇到过这个问题。不知道它是怎么来的。我什至不确定为什么 symfony 尝试使用
chmod开头 -
hmn 仔细检查子文件夹/实体
-
选中“以防万一”,但所有文件都有
-rw-rw-r--+ 1 root www-data。这里没有错 -
那么我只能想象运行网络服务器的用户不在该组中,如果你运行 apache 检查 httpd.conf 的用户和组属性
标签: doctrine-orm symfony