Symfony2 Troubleshooting - RuntimeException: Unable to create the cache directory

Issue:

"RuntimeException: Unable to create the cache directory ... " even after running point #2 under "Setting up Permissions" at http://symfony.com/doc/current/book/installation.html#configuration-and….


Systems Involved:

Symfony2, Ubuntu 13.10


Solutions and/or Notes:

This is a solution primarily for users who are using Ubuntu as their web server for their Symfony2 project.  You must be comfortable using a commandline tool.

1.) Make sure that you have ACL installed on your Ubuntu server.  Run the command to install ACL:

sudo apt-get install acl

If ACL is already installed, you should receive something similar as below:

For more in-depth information on enabling ACL for Ubuntu, check out: https://help.ubuntu.com/community/FilePermissionsACLs

2.) Make sure you're at the project root (i.e. /var/www/project), and run the commands:

  1. sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
  2. sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs

3.) Run the following commands to make sure that  www-data has been added to app/cache and app/logs.  Make sure to replace "project" with the name of your Symfony2 project's name.

  1. getfacl /var/www/project/app/cache
  2. getfacl /var/www/project/app/logs

www-data should show up similar to below (some info have been blurred for privacy purposes):

 

Note: www-data is the user under which the Apache web server runs for many distributions, so making sure this guy gets access to app/cache and app/logs will solve the issue of not being able to create directories inside of the cache directory.