apache的Vagrant同步文件夹权限问题 [英] Vagrant synced folder permission issue with apache
问题描述
我正在运行Centos6.4盒.
I'm running a Centos6.4 box.
在Vagrant文件中没有同步文件夹配置的情况下运行vagrant up
很好.我可以通过http://localhost:8080
在主机上进行访问,它显示Apache页面.我可以在/var/www/html
文件夹中创建index.html,它也可以正常显示.
Running vagrant up
without the synced folder config in Vagrant file is fine. I can access on my host machine via http://localhost:8080
and it displays the Apache page. I could create index.html in /var/www/html
folder and it displays fine too.
但是,在Vagrant文件中添加以下行之后,访问页面将显示403 Forbidden You don't have permission to access / on this server.
错误,而不是:
However after adding the line below in the Vagrant file, visiting the page displays 403 Forbidden You don't have permission to access / on this server.
error instead:
config.vm.synced_folder "./source", "/var/www/html", :extra=>"dmode=777,fmode=777"
进入虚拟机,我在/var/www
中看到如下权限设置:
Going into the VM I see the permission set as below in /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所有权,
So I tried setting apache ownership to it,
config.vm.synced_folder "./source", "/var/www/html", :owner=>"apache",:group=>"apache",:extra=>"dmode=777,fmode=777"
但是那也不行.
显然,它具有完全的读/写权限,我不知道为什么Apache在抱怨.
Apparently it has full read/write permissions and I have no clue why apache is complaining.
推荐答案
找出运行httpd的用户/组,确保用户对/var/www
及其子文件夹具有执行权限.
Figure out the user/group which runs httpd, make sure the user has execute permission on /var/www
and its subfolders.
此外,在您的Apache站点配置文件中,请确保您具有/var/www
的正确指令,如下所示:
Also, in you apache site configuration files, make sure you have correct directives for /var/www
, something like below
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
在来宾中禁用SELinux,这对开发环境毫无用处
编辑/etc/selinux/config
将SELINUX更改为已禁用
Change SELINUX to disabled
SELINUX=disabled
重新启动无业游民的盒子=> vagrant reload
Reboot the vagrant box => vagrant reload
看看#1和#2是否有帮助.
See if #1 with #2 helps.
这篇关于apache的Vagrant同步文件夹权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!