当我尝试更新composer或清除symfony项目的缓存时,我经常得到文件权限错误。然而,我的文件是根据symfony: http://symfony.com/doc/current/setup/file_permissions.html
的文档正确设置的。我在linux下,Manjaro Budgie版本(最后一个稳定版本)服务器apache最新版本
例如:
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> Incenteev'ParameterHandler'ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio'Bundle'DistributionBundle'Composer'ScriptHandler::buildBootstrap
> Sensio'Bundle'DistributionBundle'Composer'ScriptHandler::clearCache
// Clearing the cache for the dev environment with debug true
[Symfony'Component'Filesystem'Exception'IOException]
Failed to remove file "/srv/http/PetitMur/var/cache/de~/annotations/1a/5b504d5c506c6174666f726d42756e646c655c456e746974795c41727469636c652474616773405b416e6e6f745d5d5b315d.doctrinecache.data": .
该文件具有以下权限:
pierre $ la /srv/http/PetitMur/var/cache/de~/annotations...data
-rw-rw-r--+ 1 http http 234 29.09.2016 18:13 /srv/http/PetitMur/var/cache/de~/annotations...data
我知道,这个问题经常发生。但是我已经根据symfony的文档设置了权限文件。目前我必须在超级用户上运行命令才能使其工作,这是不正常的。
你有主意了吗?
编辑:php bin/symfony_requirements
Symfony Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> PHP is using the following php.ini file:
/etc/php/php.ini
> Checking Symfony requirements:
.............................WW......
[OK]
Your system is ready to run Symfony projects
Optional recommendations to improve your setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* intl extension should be available
> Install and enable the intl extension (used for validators).
* a PHP accelerator should be installed
> Install and/or enable a PHP accelerator (highly recommended).
Note The command console could use a different php.ini file
~~~~ than the one used with your web server. To be on the
safe side, please check the requirements from your web
server using the web/config.php script.
我怀疑权限和用户组设置可能不正确。
进入Apache httpd.conf文件,检查用户/组设置。您将看到这样的行:
User apache
Group apache
以上是我的系统是CentOS 6, httpd.conf在/etc/httpd/conf/
文件夹下。您的可能在不同的位置,可能是用户httpd
代替(检查它)。
然后为你的Symfony3项目设置合适的用户/组:
sudo chown -R apache:apache /srv/http/PetitMur
上面的命令将用户组设置为apache
,您可能必须使用httpd
现在删除旧的缓存文件&日志,因为它们可能是以前用错误的用户创建的:
sudo rm -rf var/cache/*
sudo rm -rf var/logs/*
然后再次运行setfacl,确保你删除了&粘贴(有一个大写X)并使用正确的用户(apache或httpd):
$ sudo setfacl -R -m u:apache:rwX -m u:`whoami`:rwX var
$ sudo setfacl -dR -m u:apache:rwX -m u:`whoami`:rwX var
然后测试一下你的系统,看看问题是否得到了解决。
我已经尝试了这个"sudo chown -R http:pierre Myproject",目前这适用于清除缓存,但不适合作曲家。