Ubuntu 10.04上的虚拟主机-禁止访问错误403



操作系统:Ubuntu 10.04 LTS

在/opt 中下载并安装了linux 1.8.1的Xampp

当我转到localhost时,我得到了标准的examplep起始页,除了phpmyadmin之外,一切都正常,我通过将"Required all Granted"行添加到external/httpd-example.conf-中修复了它

# since XAMPP 1.4.3
<Directory "/opt/lampp/phpmyadmin">
AllowOverride AuthConfig Limit
Order allow,Deny
Allow from all
#cahg 
Require all granted
</Directory>

我想开发多个站点,所以我使用我认为是标准的方法设置了虚拟主机。

  1. 在httpd.conf文件中包含额外的/httpd-vhosts.conf
  2. 在额外的/httpd-vhosts.conf文件中添加了一个虚拟主机容器。3.将以下内容添加到/etc/hosts文件

    127.0.0.1.1站点1

我一定做对了第一部分,因为它正在工作,但当我导航到"站点1"时,我的web浏览器中出现了以下错误

Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
site1
Apache/2.4.3 (Unix) OpenSSL/1.0.1c PHP/5.4.7

这个错误在我的错误日志中

[Fri Nov 16 17:14:22.481075 2012] [core:error] [pid 14465] (13)Permission denied: [client 127.0.1.1:46687] AH00035: access to / denied (filesystem path '/home/andrew/websites/site1') because search permissions are missing on a component of the path

我尝试过的解决方案是将此目录块添加到我的httpd-vhosts.conf文件中的目录标记中,该标记带有/home/andrew/websites/site作为和属性。

Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted

没有完全理解它的作用,因为这是我找到的解决方案,并且在httpd.conf中声明"You must explicitly permit access to web content directories in other <Directory> blocks below."

我的问题是:允许apache访问我的各种虚拟主机的文件的最佳方式是什么?注意:在httpd.conf中,user是nobody,group设置为nogroup。

首先在httpd.conf 中将用户nobody更改为您的ubuntu用户名

然后在httpd.conf:的末尾

# XAMPP
Include etc/extra/httpd-xampp.conf

第二,确保你的虚拟文件夹属于你的用户名(如果我的内存工作,你必须更改phpmyadmin的所有权)

然后在httpd-example.conf:中创建别名

Alias /phpmyadmin "/opt/lampp/phpmyadmin"
Alias /youralias "/path/to/folder"

然后在同一httpd-example.conf:中允许目录

<Directory "/path/to/folder">
AllowOverride AuthConfig Limit
Order allow,deny
Allow from all
Require all granted
</Directory>

再见403

最新更新