John John - 4 months ago 5
PHP Question

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

I am following the guide on symblog:

I am trying to run:

$ php composer.phar update
after updating the
but get the following error:


Failed to remove file

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).

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?

The runtime error at the end it:


An error occurred when executing the "'cache:clear --no-warmup'" command.

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?



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.

You can switch to the www-data user with

su www-data -s /bin/bash

then you should set 755 to the cache folder that the www-data has enough permissions. There is a goof explanation in the Symfony2 documentation about that.

Here in the documentation is a section "Setting up Permissions" there you can see how you can configure ACLs and other user permissions.