Apache 虚拟主机不适用于子域

Apache virtualhosts not working for subdomain

我在 ubuntu 上设置 apache 服务器时遇到问题。

我需要主域只加载一个网站,而子域加载 tomcat 服务器。 为了实现这一点,我遵循了此处的说明:https://sites.google.com/a/ci2s.com.ar/wiki/technics/how-to-run-apache-httpd-and-tomcat-on-port-80-using-mod-proxy

这没有用,主域和子域都指向同一个文件夹。 我在这里的几个答案中发现我应该包括行 NameVirtualHost *:80

然而,当我重新启动 apache 服务器时,我收到以下警告:

 AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/ginl.hodzelmanstechnology.nl.conf:1

谁能帮我解决这个问题?

一些有助于解决问题的输出:

ls /etc/apache2/sites-enabled/
ginl.hodzelmanstechnology.nl.conf  kantoor.ginl.hodzelmanstechnology.nl.conf

cat /etc/apache2/sites-available/kantoor.ginl.hodzelmanstechnology.nl.conf
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin 1353691hodzelmans@zuyd.nl
    ServerName kantoor.ginl.hodzelmanstechnology.nl/
    DocumentRoot /var/www/kantoor.ginl.hodzelmanstechnology.nl/

    ErrorLog /var/log/apache2/kantoor.ginl.hodzelmanstechnology.nl-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/kantoor.ginl.hodzelmanstechnology.nl-access.log combined
    ServerSignature Off

    # lets indicate the proxy what path do we want
    # to forward to tomcat
    ProxyPass / http://localhost:8080/

    <Directory /var/www/kantoor.ginl.hodzelmanstechnology.nl/>
            Options FollowSymLinks
            AllowOverride All
            Options -MultiViews
    </Directory>
</VirtualHost>

cat /etc/apache2/sites-available/ginl.hodzelmanstechnology.nl.conf
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin 1353691hodzelmans@zuyd.nl
    ServerName http://ginl.hodzelmanstechnology.nl/
    DocumentRoot /var/www/ginl.hodzelmanstechnology.nl/

    ErrorLog /var/log/apache2/ginl.hodzelmanstechnology.nl-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/ginl.hodzelmanstechnology.nl-access.log combined
    ServerSignature Off

    <Directory /var/www/ginl.hodzelmanstechnology.nl/>
            Options FollowSymLinks
            AllowOverride All
            Options -MultiViews
    </Directory>
</VirtualHost>

apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Mar 10 2015 13:05:59

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04
Codename:       trusty

您需要在配置文件的 "VirtualHost" 元素中定义您的子域,以便服务器可以区分不同的主机:

<VirtualHost kantoor.ginl.hodzelmanstechnology.nl:80> 
 ...
</VirtualHost>