使用nginx的Vagrant文件夹权限

使用nginx的Vagrant文件夹权限,nginx,permissions,vagrant,permission-denied,vagrantfile,Nginx,Permissions,Vagrant,Permission Denied,Vagrantfile,我是一个新的流浪者,有问题得到正确的工作。它与端口转发运行良好,我可以访问它。然而,我很难让凉亭和大口正确工作 这个问题似乎源于www-data/www-data所拥有的/var/www目录。即使将vagrant添加到www数据组中,vagrant用户也没有对任何目录的写入权限。我甚至无法使用sudo chmod向任何文件添加写入权限 每当我尝试运行bower、gulp甚至git时,我都不会遇到访问权限被拒绝的错误 任何帮助都将不胜感激 流浪者档案: # -*- mode: ruby -*- #

我是一个新的流浪者,有问题得到正确的工作。它与端口转发运行良好,我可以访问它。然而,我很难让凉亭和大口正确工作

这个问题似乎源于www-data/www-data所拥有的/var/www目录。即使将vagrant添加到www数据组中,vagrant用户也没有对任何目录的写入权限。我甚至无法使用
sudo chmod
向任何文件添加写入权限

每当我尝试运行bower、gulp甚至git时,我都不会遇到访问权限被拒绝的错误

任何帮助都将不胜感激

流浪者档案:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "hashicorp/precise32"

  config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true

  config.ssh.private_key_path = ['~/.vagrant.d/insecure_private_key', '~/.ssh/id_rsa.pub']
  config.ssh.forward_agent = true

  config.vm.synced_folder "/home/develop/b3c-dev", "/var/www", create: true, group: "vagrant", owner: "www-data"
  config.vm.synced_folder "/home/vagrant/b3c_ee/provision", "/var/provision", create: true, group: "root", owner: "root"

  config.vm.provider "virtualbox" do |v|
    v.name = "B3C Expression Engine Dev Vagrant"
    v.customize ["modifyvm", :id, "--memory", "1024"]
  end

  config.vm.provision "shell", path: "provision/setup.sh"
end
Nginx配置:

server {
    listen 80;
    server_name test.dev www.test.dev;

    root /var/www/public/;
    index index.php index.html;

    access_log /var/log/nginx/b3c-dev-access.log;
    error_log  /var/log/nginx/b3c-dev-error.log info;
    # Important for VirtualBox
    # sendfile off;

    location / {
        index index.php;
        try_files $uri $uri/ @ee;
      }

      location @ee {
        rewrite ^(.*) /index.php?$1 last;
      }

    location ~* \.php {
        include fastcgi_params;

        fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_cache off;
        fastcgi_index index.php;
    }
}

我将加载共享文件夹,并将vagrant作为所有者和组,然后
/etc/php5/fpm/pool.d/www.conf
中将用户和组更改为vagrant

要更改php fpm配置中的用户和组,只需将它们添加到
provision/setup.sh
末尾的行中:

sed -i 's/user = www-data/user = vagrant/g' /etc/php5/fpm/pool.d/www.conf
sed -i 's/group = www-data/group = vagrant/g' /etc/php5/fpm/pool.d/www.conf

如果这没有帮助,请尝试递归地增加
/var/www
的权限。

2021年,该文件是
/etc/php/8.0/fpm/pool.d/www.conf