Vagrant file_put_contents permission denied

岁酱吖の 提交于 2020-08-26 06:11:42

问题


I cannot seem to allow permissions in vagrant. I am attempting to run importbuddy.php in order to migrate a WordPress instance. I get the following error.

file_put_contents(/path/): failed to open stream: Permission denied

I have setup permissions to 777 on the www directory, but that changes nothing. Any idea on how to fix this?


回答1:


While recursively setting folder and file permissions to 777 should fix your problem (instructions for doing so here), the root of this is probably an issue with the ownership of the files and folders.

The owner of shared folders is usually 'vagrant' but the server itself (if you're using Ubuntu) runs as user and group 'www-data'. You can view the user/group of your files by sshing into your VM (vagrant ssh), navigating to the directory in question and entering ls -l in your console.

If you're running apache, then you can update the user to 'vagrant' by editing the following file (/etc/apache2/envvars) like below:

Find this section

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

And change it to

export APACHE_RUN_USER=vagrant
export APACHE_RUN_GROUP=vagrant

Afterward just be sure to restart apache (with this command sudo service apache2 restart) and the file permission errors should be fixed



来源:https://stackoverflow.com/questions/30854013/vagrant-file-put-contents-permission-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!