Permissions issues on Symfony2

Viewed 55097

This question has been asked several times but none of the solutions fix it in my situation.

I am running Apache on Mac OSX Lion. This http://localhost/Symfony/web/config.php URL triggers 2 major problems:

Change the permissions of the "app/cache/" directory so that the web server can write into it.
Change the permissions of the "app/logs/" directory so that the web server can write into it.

Following the guide under "Setting up Permissions":

rm -rf app/cache/*
rm -rf app/logs/*
sudo chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs

That doesn't solve the problems, so then I tried:

sudo chmod -R 777 app/cache

That doesn't work either. Any ideas how to fix this?

4 Answers

The Accepted answer is great however, in my case (Centos 7 & Symfony 4.3) even after setting permissions i was still getting error. It turns out SELinux was blocking Apache. The following worked for me(change my-project to your Symfony install folder).

sudo chcon -R -t httpd_sys_script_rw_t /var/www/my-project/var/cache/
sudo chcon -R -t httpd_sys_script_rw_t /var/www/my-project/var/log/

You can also disable SELinux but only temporarily for the current session to isolate the issue(I don't recommend this for prod)

sudo setenforce 0

Credits

Related