简体   繁体   English

Symfony 2.3无法使用php composer.phar更新删除文件

[英]Symfony 2.3 Failed to remove file with php composer.phar update

I am following the guide on symblog: http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html 我正在遵循symblog指南: http ://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html

I am trying to run: $ php composer.phar update after updating the composer.json but get the following error: 我试图运行: $ php composer.phar update更新后composer.json但出现以下错误:

[Symfony\\Component\\Filesystem\\Exception\\IOException] [Symfony的\\元器件\\文件系统\\异常\\ IOException异常]
Failed to remove file "/var/webroot/vhosts/mysite.co.uk/htdocs/Symfony/app/cache/dev_old/profiler/32/95/639532" 无法删除文件“/var/webroot/vhosts/mysite.co.uk/htdocs/Symfony/app/cache/dev_old/profiler/32/95/639532”

The permissions on this file is: 0644 were the owner is www-data and the group is sambashare which includes the user i am ssh'd in as (john). 此文件的权限是:0644是所有者是www-data,组是sambashare,其中包括我作为(john)ssh'd的用户。

As this is running php from command line, is php being run as 'john' thus in the group of the file wanting to be removed but not the user? 因为这是从命令行运行php,所以php是作为'john'运行的,因此在想要被删除但不是用户的文件组中?

The runtime error at the end it: 最后的运行时错误:

[RuntimeException] [RuntimeException的]
An error occurred when executing the "'cache:clear --no-warmup'" command. 执行“'cache:clear --no-warmup'”命令时发生错误。

After a bit of searching some people have just said clear this cache manually.. but how can i fix this issue at the root so i do not have to do this manually? 经过一些搜索后,有些人刚刚说过手动清除这个缓存..但是如何在root修复此问题,所以我不必手动执行此操作?

Thanks, John 谢谢,约翰

This is a common problem with Symfony2 you should run your commands under the apache2 user in most cases this is the www-data user. 这是Symfony2的一个常见问题,您应该在apache2用户下运行命令,大多数情况下这是www-data用户。

You can switch to the www-data user with 您可以使用切换到www-data用户

su www-data -s /bin/bash

then you should set 755 to the cache folder that the www-data has enough permissions. 那么你应该将755设置为缓存文件夹,使www-data具有足够的权限。 There is a goof explanation in the Symfony2 documentation about that. 在Symfony2文档中有一个关于它的蠢解释。

http://symfony.com/doc/current/book/installation.html http://symfony.com/doc/current/book/installation.html

Here in the documentation is a section "Setting up Permissions" there you can see how you can configure ACLs and other user permissions. 在文档的“设置权限”部分中,您可以看到如何配置ACL和其他用户权限。

The problem is PHP console commands use php-cli running under the current user as opposed to the web server's user (usually www-data), leading to permission errors. 问题是PHP控制台命令使用在当前用户下运行的php-cli而不是Web服务器的用户(通常是www-data),导致权限错误。

The Symfony book explains several ways to avoid the issue. Symfony的书解释了几种避免这个问题的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM