Permission settings
One common problem when installing Symfony is that the application / cache and the app / logs directories must be writable by both the web server and the command line user. On a UNIX system, if your web server user is different from your command line user, you can try one of the following solutions.
- Use the same user for CLI and web server
In development environments, it is common practice to use the same UNIX user for the CLI and the web server because it avoids any of these resolution problems when setting up new projects. This can be done by editing the configuration of your web server (for example, usually httpd.conf or apache2.conf for Apache) and setting it as a user in the same way as your CLI user (for example, for Apache, update the user and group values).
- Using ACLs on a system supporting chmod + a
Many systems allow you to use the chmod + a command. Try again, and if you get an error, try the following method. This uses the command to try to determine the user of your web server and set it as HTTPDUSER:
$ rm -rf app/cache/* $ rm -rf app/logs/* $ HTTPDUSER='ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1' $ sudo chmod +a "$HTTPDUSER 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
- Using ACLs on a system that does not support chmod + a
Some systems do not support chmod + a, but support another utility called setfacl. You may need to enable ACL support on your partition and install setfacl before using it (as is the case with Ubuntu). This uses the command to try to determine the user of your web server and set it as HTTPDUSER:
$ HTTPDUSER='ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1' $ sudo setfacl -R -mu:"$HTTPDUSER":rwX -mu:'whoami':rwX app/cache app/logs $ sudo setfacl -dR -mu:"$HTTPDUSER":rwX -mu:'whoami':rwX app/cache app/logs
For Symfony 3, it will be:
$ HTTPDUSER='ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1' $ sudo setfacl -R -mu:"$HTTPDUSER":rwX -mu:'whoami':rwX var/cache var/logs $ sudo setfacl -dR -mu:"$HTTPDUSER":rwX -mu:'whoami':rwX var/cache var/logs
If this does not work, try adding the -n option.
- Without using ACL
If none of the previous methods work for you, change umask so that the cache and log directories are writeable in a group or write all over the world (depending on whether the web server user and the command line user are in that same group or not). To achieve this, put the following line at the beginning of the app / console, web / app.php and web / app_dev.php files:
umask(0002);
Please note that using ACLs is recommended when you have access to them on your server because modifying umask is not thread safe.