简体   繁体   中英

Warning: mkdir(): Permission denied in symfony

I am trying to create new bundle in symfony but I am getting this error

Warning: mkdir(): Permission denied

I am using Mac OS and vagrant to run my symfony project.

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:

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() .

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.

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.

Hope this helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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