我已将app/cache/
目录权限设置为 0775(文件为 664)。和所有者根:www-data。这可行,但是当我清除缓存时,它会将权限变为 0755(文件变为 644)并将所有者变为 root:root。它应该这样做:
$ rm -rf app/cache/*
$ rm -rf app/logs/*
$ APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1`
$ sudo chmod +a "$APACHEUSER 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
或这个:
$ APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1`
$ sudo setfacl -R -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -dR -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/cache app/logs
但是 acl 在我的 VPS 中不起作用,并且我无法像这里所说的那样进行更改:serverfault question。我在 Symfony2 文档中看到了这一点:
Without using ACL
If you don't have access to changing the ACL of the directories, you will need to change the umask so that the cache and log directories will be group-writable or world-writable (depending if the web server user and the command line user are in the 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); // This will let the permissions be 0775
// or
umask(0000); // This will let the permissions be 0777
Note that using the ACL is recommended when you have access to them on your server because changing the umask is not thread-safe.
问题是:
有没有更安全的方法可以在没有 acl 的情况下正确设置权限?
使用是umask
一种危险的方式吗?. 在这种情况下,“非线程安全”是什么意思?