Vagrant file_put_contents 权限被拒绝 [英] Vagrant file_put_contents permission denied

查看:27
本文介绍了Vagrant file_put_contents 权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在 vagrant 中授予权限.我正在尝试运行 importbuddy.php 以迁移 WordPress 实例.我收到以下错误.

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/): 无法打开流:权限被拒绝

我在 www 目录上设置了 777 的权限,但这没有任何改变.关于如何解决这个问题的任何想法?

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

推荐答案

虽然将文件夹和文件权限递归设置为 777 应该可以解决您的问题(这样做的说明 此处),其根源可能是文件和文件夹的所有权问题.

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.

共享文件夹的所有者通常是vagrant",但服务器本身(如果您使用的是 Ubuntu)作为用户和组www-data"运行.您可以通过 ssh 进入您的 VM (vagrant ssh),导航到相关目录并在控制台中输入 ls -l 来查看文件的用户/组.

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.

如果您正在运行 apache,那么您可以通过编辑以下文件 (/etc/apache2/envvars) 将用户更新为vagrant",如下所示:

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

找到这个部分

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

并将其更改为

export APACHE_RUN_USER=vagrant
export APACHE_RUN_GROUP=vagrant

之后一定要重启apache(使用这个命令sudo service apache2 restart)并且文件权限错误应该被修复

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

这篇关于Vagrant file_put_contents 权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆