Linux 上的 Vagrant synced_folder NFS 权限问题

Vagrant synced_folder NFS permissions problems on Linux

我已经厌倦了尝试阅读 Vagrant synced_folder 的正确配置,在 CentOS 7 上使用 NFS 作为来宾,在 Elementary OS Luna 作为主机,我可以不要在共享文件夹中使用 nginx。

我的配置是这样的:

Vagrantfile

config.vm.network "private_network", ip: "192.168.0.5"
config.vm.synced_folder "/opt/lampp/htdocs", "/usr/share/nginx/html",
    owner: "vagrant",
    group: "nginx",
    mount_options: ["dmode=755,fmode=644"]

我也试过了

config.vm.synced_folder "/opt/lampp/htdocs", "/usr/share/nginx/html",
    owner: "nginx",
    group: "nginx",
    mount_options: ["dmode=755,fmode=644"]

config.vm.synced_folder "/opt/lampp/htdocs", "/usr/share/nginx/html",
    :nfs => true

以及客机中的ls命令

drwxrwxr-x. 1 vagrant nginx  4096 ene  1 21:41 .
drwxr-xr-x. 3 nginx   nginx    17 ene  1 17:57 ..
-rw-rw-r--. 1 vagrant nginx   537 sep 16 09:56 50x.html
-rw-rw-r--. 1 vagrant nginx   537 sep 16 09:56 index.html
drwxrwxr-x. 1 vagrant nginx  4096 ene  1 22:13 test

我也把 nginx 用户名改成了 vagrant。在每次更改中,我都是使用 vagrant reload 命令。

/var/log/nginx/error.log

内部
2015/01/01 22:25:01 [error] 1009#0: *1 "/usr/share/nginx/html/index.html" is forbidden (13: Permission denied), client: 192.168.0.1, server: localhost, request: "GET / HTTP/1.1", host: "192.168.0.5"

嗯,过了几天我用rsync解决了:

config.vm.synced_folder ".", "/usr/share/nginx/html", **type: "rsync"**

http://ryansechrest.com/2014/04/unable-set-permissions-within-shared-folder-using-vagrant-virtualbox/