您无权访问何时在 apache 中的单个 IP 地址上设置两个基于名称的网站

您无权访问何时在 apache 中的单个 IP 地址上设置两个基于名称的网站

Apache 安装在我的 Debian 上,我想绑定两个具有不同目录的域名。

cat  /etc/hosts
127.0.0.1  hwy.local  www.hwy.local  test.app   www.test.app

两个域名都与127.0.0.1绑定。

猫/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerName www.hwy.local
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error_hwy.log
    CustomLog ${APACHE_LOG_DIR}/access_hwy.log combined
        <Directory /var/www/html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
        </Directory>
</VirtualHost>
<VirtualHost *:80>

ServerName www.test.app
ServerAdmin webmaster@localhost
DocumentRoot  /home/debian9/app
ErrorLog ${APACHE_LOG_DIR}/error_app.log
CustomLog ${APACHE_LOG_DIR}/access_app.log combined
    <Directory /home/debian9/app>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

创建文件。

 touch  /var/log/apache2/error_hwy.log
 touch  /var/log/apache2/access_hwy.log
 touch  /var/log/apache2/error_app.log
 touch  /var/log/apache2/access_app.log
 sudo chown -R www-data:www-data /home/debian9/app
 sudo chmod -R g+rw /home/debian9/app
 sudo systemctl restart  apache2

test.html 在 和 中/var/www/html保存同一个文件/home/debian9/app

<p>it is a test</p>

为什么www.hwy.local/test.html能打开,www.test.app 就出现错误。

`This site can’t be reached` 

curl -i  www.test.app/test.html
HTTP/1.1 403 Forbidden
Date: Fri, 07 Sep 2018 09:08:13 GMT
Server: Apache/2.4.25 (Debian)
Content-Length: 296
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /test.html
on this server.<br />
</p>
<hr>
<address>Apache/2.4.25 (Debian) Server at www.test.app Port 80</address>
</body></html>

无法将DocumentRootfor设置www.test.app为 与for/home/debian9/app 不同的值?/var/www/htmlwww.hyw.local

答案1

allow from all

是Apache 2.2的配置语法。使用 Apache 2.4这应该是

Require all granted

相关内容