我已经设置了一个服务器,并创建了额外的虚拟主机,其文档根目录为 /var/www/example.com 但每当我访问 example.com 时,它都会引导至默认的“其正在工作” Apache 页面。
但是,如果我访问 example.com/example.com/index.html,它会默认显示我想要显示的代码。
感谢您的帮助。
---- 回应卡洛斯 ----
这是您请求的代码
> apache2ctl -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:
*:80 is a NameVirtualHost
default server example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost 2.example.com (/etc/apache2/sites-enabled/2.example.com.conf:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
alias www.example.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: 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
答案1
您使用 example.com 作为默认虚拟主机和第一个虚拟主机。这就是您显示默认站点而不是 example.com 站点的原因。
**:80 is a NameVirtualHost
default server example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/000-default.conf:1)*