【问题标题】:Apache2 virtual host not workingApache2 虚拟主机不工作
【发布时间】:2012-11-25 20:13:55
【问题描述】:

尝试在我的本地主机上设置 apache2 虚拟主机几天后,我严重失去了耐心。你们能帮帮我吗?一切似乎都很好,但是当我尝试在浏览器中访问 local.droidbb.com 时,我得到了

的响应

无法加载页面。加载 URL 时出现问题 http://local.droidbb.com/。无法连接到目的地。

这里是所有相关文件(至少我是这么认为的)。

etc/hosts 文件

#127.0.0.1  ingress localhost.localdomain   localhost
127.0.0.1   local.droidbb.com
#127.0.1.1  debian.resnet.gre.ac.uk debian
#127.0.1.1  debian.local.droidbb.com debian

# 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

etc/apache2/ports.conf文件

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

etc/apache2/sites-available/local.droidbb.com 文件

<VirtualHost *>

    ServerAdmin webmaster@localhost

    ServerName local.droidbb.com



    DocumentRoot /var/www/local.droidbb.com/public_html/

    <Directory />

            Options FollowSymLinks Includes -Indexes

            AllowOverride All

            Order allow,deny

            Allow from all

     </Directory>



    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    <Directory "/usr/lib/cgi-bin">

        AllowOverride None

        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

        Order allow,deny

        Allow from all

    </Directory>



    ErrorLog ${APACHE_LOG_DIR}/error.log



    # Possible values include: debug, info, notice, warn, error, crit,

    # alert, emerg.

    LogLevel warn



    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

问题出在哪里?哦,我应该提到我在 virtualbox 上运行 Linux Debian x64。

【问题讨论】:

  • 我再次安装了新机器,现在它可以正常工作了。 apache的配置可能存在一些问题。这次我在 debian 安装过程中没有勾选“安装 web-server”,而是使用了 apt-get install apache2。它现在运行完美!

标签: apache configuration apache2 webserver virtualhost


【解决方案1】:

移动文件

/etc/apache2/sites-available/local.droidbb.com

到

/etc/apache2/sites-enabled/local.droidbb.com

sites-available 中的所有内容都已禁用 :)

【讨论】:

  • 它被符号链接到由 a2ensite 命令启用的站点。无论如何,这个问题已经解决了。通过擦除 VM 并安装 Debian Wheeze :)
【解决方案2】:

apache 运行良好吗? apache的error.log中有什么东西吗?听起来像 apache 工作不正常。 (可能的配置问题或其他任何问题)

【讨论】:

  • Apache 运行没有问题。当我插入 localhost 时,默认 index.html 已加载。
猜你喜欢
  • 2016-09-29
  • 2014-05-08
  • 2016-10-26
  • 2023-03-04
  • 2017-07-23
  • 2018-12-02
  • 2014-07-04
  • 2013-04-10
相关资源
最近更新 更多