Apache vhosts 无法在 Ubuntu 14.04 LTS (Trusty Tahr) 上运行

Apache vhosts 无法在 Ubuntu 14.04 LTS (Trusty Tahr) 上运行

我正在尝试设置虚拟主机Ubuntu 14.04 LTS(Trusty Tahr)使用 Apache,但它似乎不起作用。

输出apachectl -S

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 162.210.36.172. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
162.210.36.172:80      xyz.voksul.net (/etc/apache2/sites-enabled/xyz.voksul.net.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

具体的vhost文件:

<VirtualHost 162.210.36.172:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin [email protected]
DocumentRoot /var/www/public_html/server
ServerName xyz.voksul.net
<Directory />
    Options FollowSymLinks
</Directory>
<Directory /var/www/public_html/server>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>


# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

答案1

Apache 似乎正在加载您的默认配置。这可能是因为您已定义虚拟主机,/etc/apache2/sites-available/your-site.conf但忘记将其符号链接到sites-enabled文件夹。

类似的东西sudo ln -s /etc/apache2/sites-available/your-site.conf /etc/apache2/sites-enabled/应该可以解决问题。

答案2

DNS 是否正确地将名称解析为 Apache 正在运行的 IP 地址?

本指南也许可以进一步帮助您进行配置。您可以使用 a2ensite apache 实用程序将虚拟主机从 site-available 激活为 sites-enabled,而无需手动符号链接 vhost.conf 文件。

答案3

看起来就像您这样做一样,但我想确保相关的 vhost 配置文件具有后缀.conf。Apache 2.4(至少在 Ubuntu 14.04 上配置)仅加载以.conf

在我的配置中,重命名符号链接似乎/etc/apache2/sites-enabled/还不够;我还必须重命名文件/etc/apache2/sites-available/并更新我的符号链接。

答案4

在许多情况下,问题与默认配置文件的命名有关。尝试将名称从 000-default.conf 更改为 default.conf,并在新配置文件中添加您的 vhost。问候

相关内容