我正在运行一个Centos6.4盒子。在Vagrant文件中不配置同步文件夹,运行“vagrant up”是可以的。我可以通过主机访问http://localhost:8080并显示Apache页面。我也可以在/var/www/html文件夹中创建index.html,并且它也能正常显示。但是,在Vagrant文件中添加下面这行后,访问该页面会显示“403 Forbidden You don't have permission to access / on this server.”错误:
config.vm.synced_folder "./source", "/var/www/html", :extra=>"dmode=777,fmode=777"
进入虚拟机后,我看到/var/www
的权限设置如下:
drwxr-xr-x. 6 root root 4.0K Jul 20 23:15 .
drwxr-xr-x. 18 root root 4.0K Jul 20 23:15 ..
drwxr-xr-x. 2 root root 4.0K May 14 06:12 cgi-bin
drwxr-xr-x. 3 root root 4.0K Jul 20 23:15 error
drwxrwxrwx. 1 vagrant vagrant 102 Jul 21 23:14 html
drwxr-xr-x. 3 root root 4.0K Jul 20 23:18 icons
所以我尝试将Apache的所有权设置为它,
config.vm.synced_folder "./source", "/var/www/html", :owner=>"apache",:group=>"apache",:extra=>"dmode=777,fmode=777"
但这也不起作用。
显然,它具有完全的读写权限,我不知道为什么Apache会抱怨。
SELINUX=disabled
并重新打包了它。现在它运行良好。谢谢! - resting