php symfony2 installation cache permissions

2019-01-19 07:55发布

问题:

I've downloaded 2.0.4... I can't get pass the "can't create cache directory" cause of permissions problem...

I've tried chmod 777 -R symfony -- to all folders, still can't create cache dir

I've tried setfacl but it says unrecognized -m option.... My system does not support chmod +a

I've done chown -R myuser:apache symfony -- still nothing

I've tried umask(0000) and umask(0002) in console.php/app_dev.php/app.php -- still nothing

When I refresh the page to http://localhost/symfony/web/app_dev.php, I get a SElinux alert... is this causing something? I'm not sure... all symfony content is word writable.

I'm not sure if it's me... but it's driving me nuts, maybe I just should stop using symfony2.

I'm using Fedora 13.

回答1:

It seems that you will need to switch SELinux to Permissive state. You can do so executing as root user:

setenforce 0


回答2:

PHP's umask may have no effect when default apache umask is different.

Originally I used to use setfact, but this adds overhead for deployment. What worked for me on ubuntu servers is:

  1. Set default apache umask. Edit /etc/apache2/envvars and add this line in the end of file:
umask 0002

Reload apache service

  1. Add your deploy user to www-data group, add www-data to your deploy user group.
adduser www-data `whoami` 

adduser `whoami` www-data

Logout or restart server for this to take effect.

  1. Remove app/cache, app/logs dirs

  2. Try to load page in browser, notice how app/cache dir is created by www-data user and has write group permission. Try to clear cache in console and verify that no errors occurred.

  3. Remove app/cache, app/logs dirs

  4. Run cache:clear, notice how app/cache dir is created by user deploy user and has write group permission. Try to load page in browser, and verify that no errors occurred.

Now you can forget about cache and logs permissions on this particular server for all subsequent projects.