Apache 虚拟主机无法正常工作

标签 apache virtualhost virtual-hosts server-name

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

1年前关闭。




Improve this question




不知何故,我的虚拟主机文件无法正常工作我不知道为什么 - 我敢打赌这只是我早安大脑中的一个邮件功能:p

现在,我通过指向/etc/apache2/目录中可用站点的符号链接(symbolic link)启用了两个站点,例如:

0 Nov 21 12:24 000-default -> ../sites-available/default
0 Nov 21 14:52 001-site -> ../sites-available/site

我的 VHosts 文件如下所示:

默认
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName (the IP Address from my Server)
        ServerAlias (the 2nd IP Address from my Server)
        DocumentRoot /var/www/default
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/default>
                Options FollowSymLinks MultiViews
                AllowOverride None
                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
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

地点
<VirtualHost *:80>
    ServerAdmin myname@example.de
    DocumentRoot /var/www/site/
    ServerName jobbörse-köln.de
    ServerAlias www.example.de ww.example.de w.example.de

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/site>
            Options FollowSymLinks MultiViews
            AllowOverride None
            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}/site-error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/site-access.log combined
</VirtualHost>

不知何故,当我继续“example.de”时,我进入了默认目录而不是站点目录。
甚至日志文件:
site-error.log
site-access.log

保持 0 字节......我做错了什么?我敢打赌这是一件愚蠢而简单的事情......

最佳答案

您正在为两个虚拟主机条目使用默认的 80 端口。所以我希望你使用 NameVirtualHost *:80 作为配置。

在您共享的配置中 VirtualHost 在端口 80 上重叠,因此第一个具有优先权。

关于Apache 虚拟主机无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20147305/

相关文章:

php - 如何在 PhpStorm 中为在 Vagrant 中运行的 Laravel Web 应用程序正确设置 XDebug? (Mac 操作系统)

php - 将 url 作为目录/文件/文件时,我收到 500 个内部错误

tomcat - 如何在没有 webapps 的情况下设置 tomcat 虚拟主机?

apache - Mercurial 推送,中止 : authorization failed

apache - 在不更改 URL 的情况下通过 LAN 网络从另一台计算机访问本地主机(xampp)

apache - 使用 Apache 将多个站点与一个启用 SSL 的站点结合使用

tomcat - 在 ubuntu linux 12.10 上创建虚拟主机

Apache 和 nginx 的终极配置以正确的方式为所有虚拟主机提供服务

maven - jboss-web.xml 可以访问属性吗?

php - tests.php 问题 - sipp webfrontend