我有附加的配置,我试图显示mysite.com
(在最后定义为vhost)但它总是显示默认索引页面,我在/var/www/html/domains/default/index.php
中的那个
我知道一个原因可能是我的vhost文件夹上的错误权限代码,但我不认为现在是这种情况,我没有在日志中看到常见的forbidden
错误并且出于调试目的我设置了子目录的完整路径属于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
你有vm3.mysite.com
配置在VirtualHost
块之外,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>
为了更好地组织事情,您可以考虑将这些虚拟主机移动到conf.d/<your_file>.conf
下的单独配置文件中,该文件将自动包含在主配置中。这将允许您将vhost设置与常规服务器配置分开,并避免大部分先前的混淆。