我正在尝试使用多个虚拟主机(www.domain.com& store.domain.com)设置Apache服务器,但出于某种原因,我只启用了其中一个(store.domain) .com)Apache重定向到错误的文档根目录(/ var / www),这显然是默认的。这是未正确重定向的虚拟主机配置文件:
<VirtualHost *:80>
ServerName store.domain.com
ServerAdmin mail@domain.com
DocumentRoot /var/www/store/public_html/
ErrorLog /var/www/store/logs/error.log
CustomLog /var/www/store/logs/access.log combined
</VirtualHost>
当我运行命令 apache2ctl -S 时,我得到以下内容:
Name or service not known: AH00547: Could not resolve host name *80 --ignoring!
AH00558: apache2: Could not reliably determine the server's fully qualified domain name,
using xxx.xxx.xxx.xxx. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
....
看起来密钥位于上一个错误的第一行,但我无法弄清楚错误。
当我启用以下虚拟主机时,它可以正常工作:
<VirtualHost *:80>
ServerAdmin mail@domain.com
ServerName www.domain.com
DocumentRoot /var/www/html/www/public_html/
ErrorLog /var/www/html/www/logs/error.log
CustomLog /var/www/html/www/logs/access.log combined
</VirtualHost>
启用最后一个虚拟主机后,store.domain.com会重定向到www.domain.com