Error with setfacl “Option -m: Invalid argument near character”

If you are setting permissions with the setfacl command when using Symfony or any other PHP framework that requires write access to certain directories or files, and you get the following error:

setfacl: Option -m: Invalid argument near character 3

This usually means that the user provided in the command does not exist, for example:

setfacl -R -m u:deployer:rwX -m u:apache:rwX /path

In this case, if the users deployer or apache doesn’t exist, you will get this error. You need to make sure these users exist.

If you are not sure which user Apache is using, you can run this command:

echo  `ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`