在 apache 中设置子域名

在 apache 中设置子域名

因此,我在一台服务器上有两个 Web 应用程序。我有一个主应用程序,在使用常规域时提供服务,但我希望子域指向另一个应用程序。

我已按照我在 Google 搜索中找到的方法设置了虚拟主机,但仍然不起作用。子域名仅提供主应用程序。以下是我的配置文件的内容。

<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

编辑:

我已将虚拟主机更改为使用所需的子域作为服务器名称,但仍然看到同样的问题。

<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

答案1

您的两个虚拟主机都配置了相同的服务器名称。对第二个虚拟主机使用所需的子域。

相关内容