我试图在一个Ubuntu 16.04安装上设置多个网站,到目前为止已经安装了LAMP和SSL(Letsencrypt)的Ubuntu。
问题:第一个域(website1.com)指向正确的文件夹(var / www / html / website1),但我的第二个域(website2.com)指向第一个(var / www / html / website1)。
我创build了/etc/apache2/sites-available/website1.conf和/etc/apache2/sites-available/website2.conf文件,configuration如下:
Website1.conf
<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>
Website2.conf
<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>
apachectl -S输出
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:443 is a NameVirtualHost default server website1.com (/etc/apache2/sites-enabled/website1-le-ssl.conf:2) port 443 namevhost website1.com (/etc/apache2/sites-enabled/website1-le-ssl.conf:2) alias www.website1.com port 443 namevhost website2.com (/etc/apache2/sites-enabled/website2-le-ssl.conf:2) alias www.website2.com *:80 website2.com (/etc/apache2/sites-enabled/website2.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex ssl-stapling: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/var/lock/apache2" mechanism=fcntl Mutex mpm-accept: using_defaults Mutex watchdog-callback: using_defaults Mutex rewrite-map: using_defaults Mutex ssl-stapling-refresh: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33
每次我尝试访问website2.com时,都会直接进入website1.com
请提前帮助和非常感谢您的想法!