我有一个装有Debian GNU / Linux 9(拉伸)和Apache / 2.4.25(Debian)的Linux服务器。我想在服务器上托管多个网站。例如,一个主要的网站和2-3个较小的网站供朋友使用。我还希望当对未在VHost中配置的Web服务器的请求到达时显示默认页面(例如de IP-Address)。例如,欢迎来到bla bla bla。
我想提到的是,每次更改后,我都会重新加载Web服务器,并且所有文件权限都是正确的。
我的配置
已启用网站:
000-default.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 admin@vaorra.net
DocumentRoot /websites/www/
<Directory /websites/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
# 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>
openair-seuzach.ch.conf:
<VirtualHost openair-seuzach.ch:80>
ServerName openair-seuzach.ch
ServerAdmin admin@vaorra.net
DocumentRoot /websites/openair-seuzach.ch/
<Directory /websites/openair-seuzach.ch/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
vaorra.net.conf:
<VirtualHost vaorra.net:80>
ServerName vaorra.net
ServerAdmin admin@vaorra.net
DocumentRoot /websites/vaorra.net/
<Directory /websites/vaorra.net/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
我的服务器正在运行时,您想自己对其进行测试: http://vaorra.net->应该“即将来临” http://openair-seuzach.ch->应该出现在“ Wartung!”
当您继续进行http://alligatorgfx.com/时,还会出现“ Wartung!”。但是在这个域中,我希望显示000-Default VHost Site,而不是openair-seuzach VHost中的站点。
我的apache2.conf文件:
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User- Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
谢谢!
答案 0 :(得分:0)
apachectl -S
输出表明您打算作为非默认虚拟主机的地址使用的地址规范与您打算作为默认虚拟主机的地址规范没有相同。
换句话说,第一个列出的<VirtualHost *:80>
仅是所有具有<VirtualHost *:80>
的虚拟主机的默认值。由于您具有完全匹配的内容,因此像<VirtualHost 192.168.1.0:80>
一样,Apache甚至都不会考虑通配符*:80,因此将其用作默认值/全部捕获即可。