Apache2 - 虚拟主机域路由问题

Apache2 - 虚拟主机域路由问题

我正在尝试在单个 Ubuntu 16.04 安装上设置多个网站,到目前为止已经安装了带有 LAMP 和 SSL(Letsencrypt)的 Ubuntu。

我的问题是,第一个域名(website1.com)指向正确的文件夹(var/www/html/website1),但我的第二个域名(website2.com)指向第一个(var/www/html/website1)。

我已经创建了 /etc/apache2/sites-available/website1.conf 和 /etc/apache2/sites-available/website2.conf 文件并进行如下配置:

网站1:

<IfModule mod_ssl.c><VirtualHost *:443>
ServerAdmin [email protected]
ServerName website1.com
ServerAlias www.website1.com
DocumentRoot /var/www/html/website1 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory>
<Directory /var/www/html/website1> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all
</Directory> 
    SSLCertificateFile /etc/letsencrypt/live/website2.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/website2.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

网站2:

<IfModule mod_ssl.c><VirtualHost *:443>
ServerAdmin [email protected]
ServerName website2.com
ServerAlias www.website2.com
DocumentRoot /var/www/html/website2
<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory>
<Directory /var/www/html/website2> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all
</Directory> 
    SSLCertificateFile /etc/letsencrypt/live/website2.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/website2.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

我有 a2ensite website1.conf 和 a2ensite website2.conf 我有 a2dissite 000-default.conf 和 default-ssl.conf 我也尝试过 a2ensite default-ssl.conf

每次更改后我都重新启动(sudo systemctl restart apache2)。

提前感谢您的想法!

相关内容