我正在尝试在硬件崩溃后从备份中重建服务器。我尝试安装软件并从备份中恢复配置文件,而不是恢复整个映像。但 Apache2 似乎没有遵守我的 /etc/apache2/sites-enabled/* 文件中的“ServerName”指令。/server-info 显示它正在获取正确的配置,但它没有显示我的网站,只是 /var/www/html/index.html 中的默认索引页。以下是来自 /server-info 的片段:
Module Name: core.c
Content handlers: yes
...
Current Configuration:
In file: /etc/apache2/apache2.conf
57: LockFile /var/lock/apache2/accept.lock
66: PidFile /var/run/apache2.pid
71: Timeout 300
107: MaxRequestsPerChild 0
136: AccessFileName .htaccess
156: DefaultType text/plain
167: HostnameLookups Off
175: ErrorLog /var/log/apache2/error.log
182: LogLevel warn
In file: /etc/apache2/mods-enabled/alias.conf
17: <Directory "/usr/share/apache2/icons">
18: Options Indexes MultiViews
19: AllowOverride None
: </Directory>
In file: /etc/apache2/ports.conf
8: NameVirtualHost *:80
In file: /etc/apache2/conf.d/security
27: ServerTokens Full
38: ServerSignature On
49: TraceEnable On
In file: /etc/apache2/conf.d/servername
1: ServerName xen1.xcski.com
2: ServerAdmin [email protected]
4: ServerSignature EMail
In file: /etc/apache2/sites-enabled/000-default
1: <VirtualHost *:80>
2: ServerAdmin [email protected]
4: DocumentRoot /var/www/html
5: <Directory />
6: Options FollowSymLinks
7: AllowOverride None
: </Directory>
9: <Directory /var/www/html>
10: Options Indexes FollowSymLinks MultiViews
11: AllowOverride None
: </Directory>
17: <Directory "/var/www/cgi-bin">
18: AllowOverride None
19: Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
: </Directory>
80: ErrorLog /var/log/apache2/error.log
84: LogLevel warn
87: ServerSignature EMail
: </VirtualHost>
In file: /etc/apache2/sites-enabled/rochesterflyingclub.com
2: <VirtualHost *>
3: ServerName rochesterflyingclub.com
4: ServerAlias www.rochesterflyingclub.com
5: ServerAdmin [email protected]
7: DocumentRoot /www/rochesterflyingclub.com/www
8: <Directory />
9: Options FollowSymLinks
10: AllowOverride None
: </Directory>
12: <Directory /www/rochesterflyingclub.com/www/>
13: Options Indexes FollowSymLinks MultiViews Includes
15: AllowOverride FileInfo AuthConfig Limit
: </Directory>
20: <Directory "/www/rochesterflyingclub.com/cgi-bin/">
21: AllowOverride None
22: Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
: </Directory>
27: ErrorLog /var/log/apache2/error.log
31: LogLevel warn
34: ServerSignature EMail
: </VirtualHost>
答案1
要么从第一个元素中删除 :80,要么对所有元素重复此操作。我认为最具体的地址定义优先
答案2
检查输出
apachectl -S
我认为你缺少一些配置,例如
Include /etc/apache2/sites-enabled/*
答案3
我相信您需要为虚拟主机定义端口:
<VirtualHost *:80>
...
</VirtualHost>
试试看。否则,我只是猜测,您是否尝试过查看错误/访问日志以查看文件来自何处?Apache2 并不难设置。VirtualHost 问题最常见的是拼写错误或损坏的 conf 格式。