我正在尝试在Apache上为三个子域(support。{website} .com,d1。{website} .com和s1。{website} .com)设置基于名称的虚拟主机。当我导航到这三个URL时,将获得默认VirtualHost的DocumentRoot。切换VirtualHost块的顺序(即默认主机)将切换在所有三个URL上提供的内容。
/ var / www / 的目录结构为
/var/www
├── cgi-bin
├── d1
│ └── index.html
├── html
│ └── index.html
├── s1
│ └── index.html
└── support
└── index.html
我的 /etc/httpd/conf/httpd.conf 文件以
结尾IncludeOptional conf.d/*.conf
我在 /etc/httpd/conf.d/vhosts.conf 中创建了一个.conf文件,具有与该目录(644)中默认.conf文件相同的权限,其中包含< / p>
<VirtualHost *:80>
ServerName support.{website}.com
DocumentRoot /var/www/support
</VirtualHost>
<VirtualHost *:80>
ServerName d1.{website}.com
DocumentRoot /var/www/d1
</VirtualHost>
<VirtualHost *:80>
ServerName s1.{website}.com
DocumentRoot /var/www/s1
</VirtualHost>
httpd -t 输出
Syntax OK
httpd -S 输出的第一行是
*:80 is a NameVirtualHost
default server support.{website}.com (/etc/httpd/conf.d/vhosts.conf:1)
port 80 namevhost support.{website}.com (/etc/httpd/conf.d/vhosts.conf:1)
port 80 namevhost d1.{website}.com (/etc/httpd/conf.d/vhosts.conf:6)
port 80 namevhost s1.{website}.com (/etc/httpd/conf.d/vhosts.conf:11)
我的 / var / log / httpd / access_log 文件包含连接记录(按预期),其中记录的URL包含预期的子域(节选):
{local public IP} - - [30/Jan/2019:15:30:12 +0000] "GET / HTTP/1.1" 200 76 "http://support.{website}.com/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
{local public IP} - - [30/Jan/2019:15:30:37 +0000] "GET / HTTP/1.1" 200 76 "http://d1.{website}.com/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
{local public IP} - - [30/Jan/2019:15:32:06 +0000] "GET / HTTP/1.1" 200 76 "http://s1.{website}.com/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
我的 / var / log / httpd / error_log 包含
[Wed Jan 30 15:32:36.333918 2019] [mpm_prefork:notice] [pid 12118] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Jan 30 15:32:37.388260 2019] [core:notice] [pid 12142] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed Jan 30 15:32:37.389219 2019] [suexec:notice] [pid 12142] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Jan 30 15:32:37.410253 2019] [auth_digest:notice] [pid 12142] AH01757: generating secret for digest authentication ...
[Wed Jan 30 15:32:37.410855 2019] [lbmethod_heartbeat:notice] [pid 12142] AH02282: No slotmem from mod_heartmonitor
[Wed Jan 30 15:32:37.425834 2019] [mpm_prefork:notice] [pid 12142] AH00163: Apache/2.4.6 (Red Hat Enterprise Linux) PHP/5.4.16 configured -- resuming normal operations
[Wed Jan 30 15:32:37.425859 2019] [core:notice] [pid 12142] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
重复了很多次,至少没有一个与这个问题无关。
进行更改后,我使用 sudo systemctl restart httpd 重新启动了Apache。
完整的 /etc/httpd/conf/httpd.conf 发表在https://pastebin.com/fvZFhLX1
系统版本信息:
Apache 2.4.6
Red Hat Enterprise Linux Server 7.6
Linux Kernel 3.10.0-957.1.3.el7.x86_64
我已经用尽了对这一主题的知识,但是我在网上找不到的任何东西都能解决该问题。任何帮助表示赞赏!