3个域中的2个解析为同一个DocumentRoot。单IP /多域设置。
在此处列出的情况中,domain3.tld错误地解析为与domain2.tld
相同的文档根目录这是由1and1.com托管的云服务器,我有root访问权限,Ubuntu 14.04 Apache 2.4.7服务器
在虚拟主机配置期间,使用了以下命令:a2dissite a2ensite和service apache2在激活和停用位于/ etc / apache2 / sites-available
中的虚拟主机.conf文件时重新启动apache2ctl提供了有关所有已加载虚拟主机的完整报告。显示加载的虚拟主机是正确的。
# /usr/sbin/apache2ctl -S
VirtualHost configuration:
*:8443 domain2.tld (/etc/apache2/sites-enabled/003-domain2.tld-le-ssl.conf:4)
*:80 is a NameVirtualHost
default server 70.35.204.227 (/etc/apache2/sites-enabled/000-html.conf:1)
port 80 namevhost 70.35.204.227 (/etc/apache2/sites-enabled/000-html.conf:1)
port 80 namevhost domain1.tld (/etc/apache2/sites-enabled/001-domain1.tld.conf:3)
alias www.domain1.tld
port 80 namevhost domain2.tld (/etc/apache2/sites-enabled/002-domain2.tld.conf:3)
alias www.domain2.tld
port 80 namevhost domain3.tld (/etc/apache2/sites-enabled/004-domain3.tld.conf:3)
alias www.domain3.tld
*:8080 is a NameVirtualHost
default server domain1.tld (/etc/apache2/sites-enabled/001-domain1.tld.conf:50)
port 8080 namevhost domain1.tld (/etc/apache2/sites-enabled/001-domain1.tld.conf:50)
alias www.domain1.tld
port 8080 namevhost domain2.tld (/etc/apache2/sites-enabled/002-domain2.tld.conf:49)
alias www.domain2.tld
port 8080 namevhost domain3.tld (/etc/apache2/sites-enabled/004-domain3.tld.conf:44)
alias www.domain3.tld
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
User: name="www-data" id=33
Group: name="www-data" id=33
相关目录
/etc/apache2/sites-available# ls -l
-rw-r--r-- 1 root root 1595 May 12 19:36 000-html.conf <<< IP address of server
-rw-r--r-- 1 root root 2418 May 12 20:14 001-domain1.tld.conf
-rw-r--r-- 1 root root 2517 May 12 20:14 002-domain2.tld.conf
-rw-r--r-- 1 root root 1809 May 12 20:13 003-domain2.tld-le-ssl.conf
-rw-r--r-- 1 root root 2383 May 12 20:12 004-domain3.tld.conf
/etc/apache2/sites-enabled# ls -l
lrwxrwxrwx 1 root root 32 May 12 03:52 000-html.conf -> ../sites-available/000-html.conf
lrwxrwxrwx 1 root root 43 May 12 17:40 001-domain1.tld.conf -> ../sites-available/001-domain1.tld.conf
lrwxrwxrwx 1 root root 50 May 12 17:55 002-domain2.tld.conf -> ../sites-available/002-domain2.tld.conf
lrwxrwxrwx 1 root root 57 May 12 17:41 003-domain2.tld-le-ssl.conf -> ../sites-available/003-domain2.tld-le-ssl.conf
lrwxrwxrwx 1 root root 54 May 12 18:10 004-domain3.tld.conf -> ../sites-available/004-domain3.tld.conf
每个虚拟主机配置文件都包含相关内容
<VirtualHost *:80></VirtualHost>
<VirtualHost *:8080></VirtualHost>
<VirtualHost *:8443></VirtualHost> < For SSL, not using
我正在/etc/apache2/ports.conf文件中的3个端口上监听
文件/etc/apache2/sites-available/002-domain2.tld.conf
<VirtualHost *:80>
ServerName domain2.tld
ServerAlias www.domain2.tld
#ServerAdmin Deprecated
DocumentRoot /var/www/html-domain2.tld
ErrorLog ${APACHE_LOG_DIR}/error-port80-domain2.tld.log
CustomLog ${APACHE_LOG_DIR}/access-port80-domain2.tld.log combined
</VirtualHost>
<VirtualHost *:8080>
ServerName domain2.tld
ServerAlias www.domain2.tld
#ServerAdmin Deprecated
DocumentRoot /var/www/html-domain2.tld
ErrorLog ${APACHE_LOG_DIR}/error-port8080-domain2.tld.log
CustomLog ${APACHE_LOG_DIR}/access-port8080-domain2.tld.log combined
</VirtualHost>
文件/etc/apache2/sites-available/004-domain3.tld.conf
<VirtualHost *:80>
ServerName domain3.tld
ServerAlias www.domain3.tld
#ServerAdmin Deprecated
DocumentRoot /var/www/html-domain3.tld
ErrorLog ${APACHE_LOG_DIR}/error-port80-domain3.tld.log
CustomLog ${APACHE_LOG_DIR}/access-port80-domain3.tld.log combined
</VirtualHost>
<VirtualHost *:8080>
ServerName domain3.tld
ServerAlias www.domain3.tld
#ServerAdmin Deprecated
DocumentRoot /var/www/html-domain3.tld
ErrorLog ${APACHE_LOG_DIR}/error-port8080-domain3.tld.log
CustomLog ${APACHE_LOG_DIR}/access-port8080-domain3.tld.log combined
</VirtualHost>
知道为什么我的域3被定向到与域2相同的文档根目录?我看到拥有100个虚拟主机的虚拟主机完全正常工作,但不是我正在进行的这个简单的设置。已经在这3天尝试了我在这里和那里的几个论坛找到的各种修复方案。
持续诊断发现:第5天 如果删除了domain3 DocumentRoot的内容,则Apache会提供空白页面。恢复domain3 DocumentRoot的内容后,将再次提供domain2 DocumentRoot的内容。这种行为是可重复的。