禁止Apache2虚拟主机403?

Pet*_*sen 42 ubuntu apache2 virtualhost http-status-code-403

我在桌面上运行ubuntu 13.04 64bit,我安装了Apache2,MySQL和PHP等.

我想让我的网络根目录/home/afflicto/public_html而不是/var/www.于是我就跟着去了本指南:
http://www.maketecheasier.com/install-and-configure-apache-in-ubuntu/2011/03/09
(我所做的一切,从"配置不同的网站"),因为我喜欢解决更多.

这就是我所做的:
安装Apache2,MySQL等..
复制/etc/apache2/sites-avaliable/default/etc/apache2/sites-available/afflicto.然后编辑它,它现在看起来如下:

在/ etc/apache2的/网站可用/ afflicto

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/afflicto/public_html
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /home/afflicto/public_html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>  
Run Code Online (Sandbox Code Playgroud)

我做到了 sudo a2dissite default && sudo a2ensite afflicto && sudo service apache2 restart

我创建了一个index.phpindex.html/home/afflicto/public_html/test/
访问时localhost/testlocalhost/test/index.html等,我得到403 Forbidden错误.

我究竟做错了什么?提前致谢.

更新1
我已将public_html目录的所有者设置为www-data.
此外sudo chmod -R +x public_html && sudo chmod -R 777 public_html
还有相同的403错误.

这是apache错误日志的输出:

[Sun Jul 14 06:10:32 2013] [error] [client 127.0.0.1] (13)Permission denied: access to / denied

[Sun Jul 14 06:10:32 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /favicon.ico denied
Run Code Online (Sandbox Code Playgroud)

Pet*_*ter 105

我遇到了这个问题.但我不喜欢将我的主目录组更改为www-data的想法.可以通过修改virtualHost的配置文件来简单地解决此问题.只需配置Directory标记即可包含这些内容

<Directory "your directory here">
   Order allow,deny
   Allow from all
   Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)

Require all granted是我猜的一个新功能; 默认值为denied.

有关详细信息,请参阅此页面:http://httpd.apache.org/docs/current/mod/core.html#directory

  • "要求全部授予"是黄金.非常感谢! (8认同)
  • 2.4显然不需要订购和允许 (3认同)
  • 就我而言,我还需要执行此操作“chmod +x /home/(username)”,http://www.andrewklau.com/permission-denied-because-search-permissions-are-missing-on-a-component -路径/ (2认同)

Pet*_*sen 20

结果我不仅要chmod /home/afflicto/public_html而且还要有/home/afflicto/目录.

奇怪的.

  • 正确.apache进程必须能够访问路径中的每个目录.此外,apache进程要求每个目录都具有全局访问权限,或者它不会将目录提供给(外部)世界. (7认同)
  • 一点儿都不奇怪.您声明的`DocumentRoot`是`/ home/afflicto/public_html`,因此Apache需要访问. (2认同)