Apache 为什么此配置总是显示我的默认web服务器?

Apache 为什么此配置总是显示我的默认web服务器?,apache,debugging,web,webserver,virtualhost,Apache,Debugging,Web,Webserver,Virtualhost,我有附加的配置,我试图显示mysite.com(在最后定义为vhost),但它总是显示默认的索引页,我在/var/www/html/domains/default/index.php 我知道一个原因可能是vhost文件夹上的权限代码错误,但我认为现在不是这样,我在日志中没有看到常见的禁止的错误,为了调试,我将子目录的完整路径设置为属于apache:apache 我还试图将vhost移到.conf的顶部,但没有什么不同 ServerRoot "/etc/httpd" Listen *:80 L

我有附加的配置,我试图显示
mysite.com
(在最后定义为vhost),但它总是显示默认的索引页,我在
/var/www/html/domains/default/index.php

我知道一个原因可能是vhost文件夹上的权限代码错误,但我认为现在不是这样,我在日志中没有看到常见的
禁止的
错误,为了调试,我将子目录的完整路径设置为属于
apache:apache

我还试图将vhost移到.conf的顶部,但没有什么不同

ServerRoot "/etc/httpd"


Listen *:80
Listen *:443

Include conf.modules.d/*.conf


User apache
Group apache


ServerAdmin root@localhost


ServerName vm3.mysite.com:80

<Directory />
    AllowOverride all
    Require all granted
</Directory>



DocumentRoot "/var/www/html/domains/default"

<Directory "/var/www">
    AllowOverride All
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks


    AllowOverride All

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>


EnableSendfile on

IncludeOptional conf.d/*.conf


<VirtualHost mysite.com:80>
        DocumentRoot /var/www/html/domains/mysite.com
        ServerName mysite.com
        <Directory "/var/www/html/domains/mysite.com">
                allow from all
                Options None
                Require all granted
        </Directory>
</VirtualHost>


KeepAlive on
ServerRoot”/etc/httpd
听*:80
听*:443
包括conf.modules.d/*.conf
用户apache
组apache
服务器管理员root@localhost
ServerName vm3.mysite.com:80
允许超越所有
要求所有授权
DocumentRoot“/var/www/html/domains/default”
允许超越所有
要求所有授权
选项索引跟随符号链接
允许超越所有
要求所有授权
DirectoryIndex.html
要求全部拒绝
错误日志“日志/错误日志”
日志级别警告
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\”%>s%b”通用
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\“%%{User Agent}i\%i%O”组合IO
CustomLog“日志/访问日志”组合
ScriptAlias/cgi-bin/“/var/www/cgi-bin/”
不允许超限
选项无
要求所有授权
TypesConfig/etc/mime.types
AddType应用程序/x-compress.Z
AddType应用程序/x-gzip.gz.tgz
AddType text/html.shtml
AddOutputFilter包括.shtml
AddDefaultCharset UTF-8
MIMEMagicFile conf/magic
在上启用SendFile
IncludeOptional conf.d/*.conf
DocumentRoot/var/www/html/domains/mysite.com
服务器名mysite.com
通融
选项无
要求所有授权
继续

您在
VirtualHost
块之外配置了
vm3.mysite.com
,apache正在无条件地使用该块并忽略
mysite.com
vhost。您可以通过将
vm3.mysite.com
移动到单独的vhost中来解决这个问题(它们出现在配置文件中并不重要,只要它们都在vhost中)

这是您的配置,为了清晰起见,对一些指令进行了重新组织,并将相关位移到底部适当的
VirtualHost
块中:

ServerRoot "/etc/httpd"

Listen *:80
Listen *:443

User apache
Group apache

KeepAlive on
EnableSendfile on
Include conf.modules.d/*.conf
IncludeOptional conf.d/*.conf

<Directory "/var/www">
    AllowOverride All
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

<VirtualHost vm3.mysite.com:80>
    ServerAdmin root@localhost
    ServerName vm3.mysite.com
    DocumentRoot "/var/www/html/domains/default"
    <Directory />
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost mysite.com:80>
    DocumentRoot /var/www/html/domains/mysite.com
    ServerName mysite.com
    <Directory "/var/www/html/domains/mysite.com">
        allow from all
        Options None
        Require all granted
    </Directory>
</VirtualHost>
ServerRoot”/etc/httpd
听*:80
听*:443
用户apache
组apache
继续
在上启用SendFile
包括conf.modules.d/*.conf
IncludeOptional conf.d/*.conf
允许超越所有
要求所有授权
选项索引跟随符号链接
允许超越所有
要求所有授权
DirectoryIndex.html
要求全部拒绝
错误日志“日志/错误日志”
日志级别警告
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\”%>s%b”通用
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\“%%{User Agent}i\%i%O”组合IO
CustomLog“日志/访问日志”组合
ScriptAlias/cgi-bin/“/var/www/cgi-bin/”
不允许超限
选项无
要求所有授权
TypesConfig/etc/mime.types
AddType应用程序/x-compress.Z
AddType应用程序/x-gzip.gz.tgz
AddType text/html.shtml
AddOutputFilter包括.shtml
AddDefaultCharset UTF-8
MIMEMagicFile conf/magic
服务器管理员root@localhost
ServerName vm3.mysite.com
DocumentRoot“/var/www/html/domains/default”
允许超越所有
要求所有授权
DocumentRoot/var/www/html/domains/mysite.com
服务器名mysite.com
通融
选项无
要求所有授权
<>为了更好地组织事物,你可以考虑将这些Vists移到一个单独的配置文件中,在COND.D/.CONF中,这将自动包含在主配置中。这将允许您将vhost设置与常规服务器配置分开,并避免以前的大多数混淆