因此,我在一台服务器上有两个 Web 应用程序。我有一个在使用常规域时提供的主域,但我希望一个子域指向另一个应用程序。
我已经按照我在谷歌搜索中找到的方式设置了虚拟主机,但它仍然不起作用。子域只是提供主应用程序。这是我的配置文件的内容。
<VirtualHost *:80>
ServerName www.luketimoth.me
DocumentRoot /var/www/luketimothy/public
<Directory /var/www/luketimothy/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.luketimoth.me
DocumentRoot /var/www/shattered-plays/public
ServerAlias shattered.luketimoth.me
<Directory /var/www/shattered-plays/public>
PassengerEnabled on
</Directory>
</VirtualHost>
据我所知(以我对 Apache 的初学者/基本知识),这应该符合我的期望......但事实并非如此。我究竟做错了什么?
的输出httpd -S
httpd: apr_sockaddr_info_get() failed for LMTServe
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Sat May 17 16:42:02 2014] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 www.luketimoth.me (/etc/httpd/conf/httpd.conf:1017)
*:80 www.luketimoth.me (/etc/httpd/conf/httpd.conf:1031)
Syntax OK
编辑:
我已更改虚拟主机以使用所需的子域作为 ServerName,但我仍然看到同样的问题。
<VirtualHost *:80>
ServerName www.luketimoth.me
DocumentRoot /var/www/luketimothy/public
<Directory /var/www/luketimothy/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName shattered.luketimoth.me
DocumentRoot /var/www/shattered-plays/public
<Directory /var/www/shattered-plays/public>
PassengerEnabled on
</Directory>
</VirtualHost>
httpd: apr_sockaddr_info_get() failed for LMTServe
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Sun May 18 10:15:24 2014] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 www.luketimoth.me (/etc/httpd/conf/httpd.conf:1017)
*:80 shattered.luketimoth.me (/etc/httpd/conf/httpd.conf:1031)
Syntax OK
您的两个虚拟主机都配置为相同的服务器名称。第二个使用所需的子域。