简体   繁体   English

警告:mkdir():symfony 中的权限被拒绝

[英]Warning: mkdir(): Permission denied in symfony

I am trying to create new bundle in symfony but I am getting this error我正在尝试在 symfony 中创建新包,但出现此错误

Warning: mkdir(): Permission denied警告:mkdir():权限被拒绝

I am using Mac OS and vagrant to run my symfony project.我正在使用 Mac OS 和 vagrant 来运行我的 symfony 项目。

How I can get rid of this problem?我怎样才能摆脱这个问题?

First, you need to find out which user your web-server runs under.首先,您需要找出您的网络服务器在哪个用户下运行。 This can vary from www-data , fpm , apache , http , etc. One, rather painless, way (but not % accurate) is from Symfony 's docs:这可能与www-datafpmapachehttp等不同。一种相当轻松的方式(但不是 % 准确)来自Symfony的文档:

echo $(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)

Once you find out that piece of info, you need to configure permissions to parent directory in which you wanted to run mkdir() .找到该信息后,您需要配置要在其中运行mkdir()父目录的权限。

You can either alter ownership of directory:您可以更改目录的所有权:

chown -R <user>:<user> <parent-directory>
chmod -R 664 <parent-directory> 

This will set ownership of directory to user and change permissions to RW to owner and group.这会将目录的所有权设置为用户,并将RW权限更改为所有者和组。

Another strategy, would be to find out if group is allowed to RW to parent directory and then add web user to that group, but it really depends on your preferences if you want to do it this way.另一种策略是找出是否允许组RW到父目录,然后将网络用户添加到该组,但如果您想这样做,这实际上取决于您的偏好。

Hope this helps...希望这可以帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM