Accessing Vagrant folder using nginx

I am new to vagrant and have trouble getting it working properly. It works fine with port forwarding and I can access it. However, I am having trouble getting the benches and gulp to work correctly.

The problem seems to be related to the fact that the / var / www directory is owned by www-data / www-data. The vagrant user does not have write permissions to any of the directories even after adding the vagrants to the www-data group. I can't even use sudo chmod

to add write permission to any file.

I don't get any access denied denied every time I run a conversation, gulp, or even git.

Any help would be greatly appreciated.

Vagrant file:

# -*- 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 config:

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;
    }
}

      

+3


source to share


2 answers


I would upload the shared folder vagrant as owner and group and then change the user and group to vagrant in/etc/php5/fpm/pool.d/www.conf

.

To change user and group in php-fpm config, just add them to the end of the lines 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

      

If that doesn't work, try increasing the resolution /var/www

recursively.

+5


source


It's also worth noting that your config.ssh.private_key_path points to your public key instead of your private key.



-1


source







All Articles