Apache 虚拟主机不适用于子域
Posted
技术标签:
【中文标题】Apache 虚拟主机不适用于子域【英文标题】:Apache virtualhosts not working for subdomain 【发布时间】:2015-05-27 14:53:58 【问题描述】:我在 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>
【讨论】:
以上是关于Apache 虚拟主机不适用于子域的主要内容,如果未能解决你的问题,请参考以下文章
Apache2 使用 Django 项目设置带有子域的虚拟主机
RewriteRules 和 ErrorDocument 规则不适用于 SSL 虚拟主机