2016-10-19 74 views
0

我已經安裝在VirtualBox中一個centos7,在它運行的Apache httpd的,MariaDB的,phpMyAdmin的等,主機的MacOSapache httpd的地圖網址到VirtualBox的共享文件夾

,當我嘗試將URL映射到一個共享文件夾,我遇到錯誤

Forbidden: You don't have permission to access /tutorial/ on this server. 

須藤尾-f /無功/日誌/的httpd/error_log中

[Wed Oct 19 22:48:23.108758 2016] [autoindex:error] [pid 1469] (13)Permission denied: [client 192.168.144.1:51847] AH01275: Can't open directory for index: /php-tutorial/www/ 

/etc/httpd/conf.d/tutorial.conf

Alias /tutorial "/php-tutorial/www" 

<Directory "/php-tutorial/www"> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Require all granted 
</Directory> 

文件夾的權限是

drwxr-xr-x. 1 vagrant vagrant system_u:object_r:vmblock_t:s0 /php-tutorial/www 
drwxr-xr-x. 1 vagrant vagrant system_u:object_r:vmblock_t:s0 /php-tutorial 
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www 
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html 

我不知道這是否是可能的,如果可能的話,什麼是配置它的正確方法。

回答

0

感謝以斯拉-S突出顯示可能出現的問題。

是的,這是因爲SELinux,因爲在此處使用的來賓操作系統Centos 7.2中默認啓用了SELinux。

有此問題的兩種不同的解決方案:

  1. 快速的解決方案,禁用SELinux

    # vi /etc/selinux/config 
    
    SELINUX=enforcing # <= change enforcing to disabled 
    
  2. 更好的解決方案定製SELinux策略

    # yum install -y policycoreutils-python 
    # vi httpd_t.te 
    
    module httpd_t 1.0; 
    
    require { 
         type httpd_t; 
         type vmblock_t; 
         class file { read getattr open }; 
    } 
    
    #============= httpd_t ============== 
    allow httpd_t vmblock_t:file { read getattr open }; 
    
    # checkmodule -M -m -o httpd_t.mod httpd_t.te 
    # semodule_package -o httpd_t.pp -m httpd_t.mod 
    # semodule -i httpd_t.pp 
    # systemctl restart httpd 
    

參考文獻:

  1. https://github.com/mitchellh/vagrant/issues/6970,有人遇到同樣的問題,並找到了一步一步的出路。
  2. https://wiki.centos.org/HowTos/SELinux,關於SELinux的一個很好的介紹。
0

你似乎有SELinux的,審查SELinux的日誌

相關問題