Apache 虚拟主机无法在 Ubuntu 14.04 LTS 上运行

Apache 虚拟主机无法在 Ubuntu 14.04 LTS 上运行

我一直在使用本教程在我的 Ubuntu PC 上设置 Apache 虚拟主机。我创建了一个no-ip domain将用作虚拟主机的主机名。我已按照教程的每一步操作,但它不起作用。这是虚拟主机文件,其名称为crm2plus.ddns.net.conf

<VirtualHost *: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]
        ServerName  crm2plus.ddns.net
        ServerAlias crm2plus.ddns.net
        DocumentRoot /var/www/crm2plus.ddns.net/public_html

        # 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>
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我还将 IP 和域名对添加到本地主机文件中,如下所示:

23.253.21.201   shhasan.ddns.net
127.0.1.1       Ubuntu-Dev
127.0.0.1       localhost
99.250.71.177   crm2plus.ddns.net

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

当我通过 chrome 导航时,crm2plus.ddns.net我得到了web page not available page.shhasan.ddns.net工作正常。当我ssh-keygen -H -F crm2plus.ddns.net在终端中输入时,什么也没有显示,但是当我输入时,ssh-keygen -H -F shhasan.ddns.net会显示以下内容:

# Host shhasan.ddns.net found: line 14 type RSA

接下来是 RSA 密钥。

我还查看了 Apache 错误和访问日志。错误日志中有很多这样的代码行重复:

[Fri Nov 14 17:44:50.304782 2014] [mpm_prefork:notice] [pid 21927] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Fri Nov 14 17:44:50.304801 2014] [core:notice] [pid 21927] AH00094: Command line: '/usr/sbin/apache2'
[Fri Nov 14 17:44:54.979832 2014] [mpm_prefork:notice] [pid 21927] AH00169: caught SIGTERM, shutting down

我搜索了一下caught SIGTERM, shutting down,发现这是正常操作的一部分。我不知道我哪里错了。它以前适用于shhasan.ddns.net但不适用于crm2plus.ddns.net.

输出netstat -pan | grep 80

unix  2      [ ]         STREAM     CONNECTED     528079   5594/gvfsd-http     @/dbus-vfs-daemon/socket-vc8j6I1O
unix  3      [ ]         STREAM     CONNECTED     18079    2579/dbus-daemon    @/tmp/dbus-nICf5nhpay
unix  3      [ ]         STREAM     CONNECTED     18067    2579/dbus-daemon    @/tmp/dbus-nICf5nhpay
unix  2      [ ]         DGRAM                    8009     -                   
unix  3      [ ]         STREAM     CONNECTED     18116    2680/indicator-appl 
unix  3      [ ]         STREAM     CONNECTED     18076    2488/dbus-daemon    @/tmp/dbus-PTGbrLg1OB
unix  3      [ ]         STREAM     CONNECTED     18085    2587/ibus-ui-gtk3   
unix  2      [ ]         STREAM     CONNECTED     528093   5594/gvfsd-http     @/dbus-vfs-daemon/socket-XXVPW75v
unix  3      [ ]         STREAM     CONNECTED     20680    2827/compiz         
unix  3      [ ]         STREAM     CONNECTED     18072    2488/dbus-daemon    @/tmp/dbus-PTGbrLg1OB
unix  3      [ ]         STREAM     CONNECTED     225804   4011/chrome         
unix  3      [ ]         STREAM     CONNECTED     18008    2488/dbus-daemon    @/tmp/dbus-PTGbrLg1OB
unix  3      [ ]         STREAM     CONNECTED     228060   2541/ibus-daemon    @/tmp/dbus-8s7gwnYp
unix  3      [ ]         STREAM     CONNECTED     18071    2488/dbus-daemon    @/tmp/dbus-PTGbrLg1OB
unix  3      [ ]         STREAM     CONNECTED     225280   4011/chrome         
unix  3      [ ]         STREAM     CONNECTED     18069    2607/at-spi2-regist 
unix  3      [ ]         STREAM     CONNECTED     18001    2501/window-stack-b 
unix  2      [ ]         STREAM     CONNECTED     9700589  5594/gvfsd-http     @/dbus-vfs-daemon/socket-80dWj6IE
unix  3      [ ]         STREAM     CONNECTED     18044    2488/dbus-daemon    @/tmp/dbus-PTGbrLg1OB

答案1

虚拟主机定义的稍微编辑版本RiggsFolly 在 stackoverflow 上的回答为**工作crm2plus.ddns.net

<VirtualHost *:80>

    ServerName crm2plus.ddns.net
        ServerAlias crm2plus.ddns.net
    ServerRoot /var/www/crm2plus.ddns.net/
    DocumentRoot /var/www/crm2plus.ddns.net/public_html

    <Directory "/var/www/crm2plus.ddns.net/public_html">
        Options +Indexes +FollowSymLinks
        Order allow,deny
        Allow from all
        AllowOverride All
    </Directory>


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

    ErrorLog ${APACHE_LOG_DIR}/crm2plus.ddns.net_error.log
    CustomLog ${APACHE_LOG_DIR}/crm2plus.ddns.net_access.log combined


</VirtualHost>

答案2

对于未来有关 Apache 2.4 虚拟主机的配置,您也可以使用本指南 http://www.bytelinux.com/enable-apache-virtual-hosting-ubuntu-14-10/作为虚拟主机配置文件必须是什么样子的起点!

相关内容