gpt4 book ai didi

ubuntu - Apache2 虚拟主机 403 被禁止?

转载 作者:太空宇宙 更新时间:2023-11-03 16:40:49 25 4
gpt4 key购买 nike

我在我的桌面上运行 ubuntu 13.04 64 位,我安装了 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/sites-available/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>

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

我在 /home/afflicto/public_html/test/
创建了一个 index.phpindex.html当访问 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

最佳答案

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

<Directory "your directory here">
Order allow,deny
Allow from all
Require all granted
</Directory>

我猜 Require all granted 是一个新特性;默认值为 denied

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

关于ubuntu - Apache2 虚拟主机 403 被禁止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17636389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com