清除缓存时使用umask设置权限(Using umask to set permission when clearing cache)

编程入门 行业动态 更新时间:2024-10-22 23:04:02
清除缓存时使用umask设置权限(Using umask to set permission when clearing cache)

我无法使用ACL,所以我尝试将umask(0000)添加到我的VPS中的app / console和web / app.php,但app / cache的权限再次转为0755,所有者组转为myFTPUser当我清除缓存时,我的网站会抛出一个错误,直到我再次将权限更改为0775并将组所有者更改为www-data :

php app/console cache:clear --env=prod --no-debug chown -R myFTPUser:www-data app/cache/ find app/cache/ -type d | xargs chmod -R 0775 find app/cache/* -type f | xargs chmod -R 0664

我发现的唯一方法是在清除缓存之前将用户更改为Apache用户,而不更改umask :

su www-data php app/console cache:clear --env=prod --no-debug

现在它可以正常运行而无需做任何其他事情。 但是,这是正确的方法吗? 并且,为什么Symfony2文档没有澄清这一点?

I can't use ACL, so I've tried to add umask(0000) to the app/console and web/app.php in my VPS, but the permissions of app/cache are turned again to 0755 and owner group to myFTPUser when I clear cache, so my site throws an error until I change permissions again to 0775 and group owner to www-data:

php app/console cache:clear --env=prod --no-debug chown -R myFTPUser:www-data app/cache/ find app/cache/ -type d | xargs chmod -R 0775 find app/cache/* -type f | xargs chmod -R 0664

The only way I've found out is to change user to Apache user before clear cache, without changing umask:

su www-data php app/console cache:clear --env=prod --no-debug

And now it works right without doing anything else. But, is it the right way to go? and, why Symfony2 documentation doesn't clarify this point?

最满意答案

您必须从apache用户运行此命令。

如果这是一个开发环境,那么将用户设置为您自己的用户并不是一件坏事。 但是在生产环境中,您很可能只需要切换到apache用户。

You will have to run this command from the apache user.

If this is a development environment then it's not a bad thing to set the user to your own user. However in a production environment you would more than likely just have to switch to the apache user.

更多推荐

本文发布于:2023-08-01 04:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1353744.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   权限   umask   set   clearing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!