我在 Digital Ocean Droplet 上成功设置了多个子域名作为虚拟主机。但由于某种原因,我的最新子域名正在为不同的子域名提供服务,我不确定为什么。因此,如果您访问selingo.mikeheavers.com
它,它将为 的内容提供服务exhibitcolumbus.mikeheavers.com
。此外,如果您只输入我的 droplet 的 IP 地址,它将提供服务exhibitcolumbus.mikeheavers.com
- 我希望它只为 提供服务mikeheavers.com
。我搞混了什么?
我通过 .conf 文件设置了两个子域名,并且sudo a2ensite [file.com.conf]
这是 selingo.mikeheavers.com.conf 的内容:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerAdmin [email protected]
ServerName selingo.mikeheavers.com
ServerAlias www.selingo.mikeheavers.com
DocumentRoot /var/www/selingo/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel warn rewrite:trace8
RewriteEngine On
RewriteCond %{SERVER_NAME} =selingo.mikeheavers.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
这是 exhibitcolumbus.com.conf:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName exhibitcolumbus.mikeheavers.com
ServerAlias www.exhibitcolumbus.mikeheavers.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/exhibitcolumbus/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel warn rewrite:trace8
RewriteEngine on
RewriteCond %{SERVER_NAME} =exhibitcolumbus.mikeheavers.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
我也在我的/etc/hosts
文件中注意到了这一点,但我不确定第一个条目来自哪里 - 我不记得设置它:
127.0.1.1 extra extra
127.0.0.1 localhost
我也在使用 letsencrypt 进行 SSL,所以这可能导致问题?我看到它也创建了一些 conf 文件,但它们基本上与上面的相同,但添加了:
SLCertificateFile /etc/letsencrypt/live/exhibitcolumbus.mikeheavers.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/exhibitcolumbus.mikeheavers.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/exhibitcolumbus.mikeheavers.com/chain.pem
我还为 droplet 上的每个子域名设置了指向我的 IP 地址的 A 记录(http://107.170.120.88/),奇怪的是它也没有提供我的主域名(应该是你在 mikeheavers.com 上看到的)
当我输入时,我看到了这一点apachectl -S
:
AH00112: Warning: DocumentRoot [/var/www/html] does not exist
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 exhibitcolumbus.mikeheavers.com (/etc/apache2/sites-enabled/exhibitcolumbus.mikeheavers.com-le-ssl.conf:2)
port 443 namevhost exhibitcolumbus.mikeheavers.com (/etc/apache2/sites-enabled/exhibitcolumbus.mikeheavers.com-le-ssl.conf:2)
alias www.exhibitcolumbus.mikeheavers.com
port 443 namevhost mikeheavers.com (/etc/apache2/sites-enabled/mikeheavers.com-le-ssl.conf:2)
port 443 namevhost prototypes.mikeheavers.com (/etc/apache2/sites-enabled/prototypes.mikeheavers.com-le-ssl.conf:2)
*:80 is a NameVirtualHost
default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost exhibitcolumbus.mikeheavers.com (/etc/apache2/sites-enabled/exhibitcolumbus.mikeheavers.com.conf:1)
alias www.exhibitcolumbus.mikeheavers.com
port 80 namevhost mosaic.mikeheavers.com (/etc/apache2/sites-enabled/mosaic.mikeheavers.com.conf:1)
port 80 namevhost prototypes.mikeheavers.com (/etc/apache2/sites-enabled/prototypes.mikeheavers.com.conf:1)
port 80 namevhost selingo.mikeheavers.com (/etc/apache2/sites-enabled/selingo.mikeheavers.com.conf:1)
alias www.selingo.mikeheavers.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
我该如何解决我所造成的混乱?
答案1
您尚未创建虚拟主机来提供服务https://selingo.mikeheavers.com/。因此,当访问此 URL 时,Apache 将选择默认虚拟主机,根据您的列表,该主机为default server exhibitcolumbus.mikeheavers.com
。
您只需要创建一个新的虚拟主机来为该网站提供服务。