i have install lampp 1.8.1 in /opt/lampp.Everything is working fine.

i added my current user as owner to the htdocs folder so that i can write to htdocs folder.

then i created my symfony2 project. everything worked fine and i was able to run the configuration page properly.

but when i cleared the cache using command

sudo php app/console cache:clear --env=prod
sudo php app/console cache:clear --env=dev

the cache gets cleared but then there is permissions issue. when i try to access the same configuration page as before it gives me an error in browser:

" RuntimeException: Failed to write cache file "/opt/lampp/htdocs/Symfony/app/cache/dev/classes.php"."

but then when i change the permissions of the cache folder again using :

sudo chmod -R 777 app/cache

the page is again displayed properly

I dont want to change permissions everytime after clearing the cache. Is there a solution or am i doing something wrong?

  • What are the app/cache permissions and ownership ls -l app/cache after you clear the cache? – Richard Ayotte Feb 23 '13 at 1:39

See "Setting up Permissions" in http://symfony.com/doc/current/book/installation.html#configuration-and-setup. My preferred way in Ubuntu is setfacl, it works (just need to install a package first time):

sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
  • 2
    Do sudo apt-get install acl if there is no command setfacl on your host – userlond Oct 3 '15 at 4:02

if user don't have root privileges correct is

su root 
export user="changeToYouUsername"

setfacl -R -m u:www-data:rwX -m u:$user:rwX app/cache app/logs
setfacl -dR -m u:www-data:rwx -m u:$user:rwx app/cache app/logs

this example

sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs

work only if current user have root and this is web log user (if we do it from root account - persmissions fail - it use $whoami as user name


With symfony3

sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX var/cache var/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx var/cache var/logs

works for me.

  • I doubt that the commands will help in the specific case, but this may point in the right direction. – mook765 Oct 8 '16 at 6:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.