Sunday, November 2, 2014

Why isn't Apache recognizing my VirtualHosts ServerName?



I am trying to reconstruct a server from backups after a hardware crash. Rather than restore the entire image, I'm trying a combination of installing software and then restoring configuration files from backups. But Apache2 doesn't seem to be honouring the "ServerName" directives in my /etc/apache2/sites-enabled/* files. /server-info shows that it's picking up the right configuration, but it's not displaying my sites, just the default index page in /var/www/html/index.html. Here's a snippet from /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:
18: Options Indexes MultiViews
19: AllowOverride None
:

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 ptomblin@xcski.com
4: ServerSignature EMail
In file: /etc/apache2/sites-enabled/000-default

1:
2: ServerAdmin ptomblin@xcski.com
4: DocumentRoot /var/www/html
5:
6: Options FollowSymLinks
7: AllowOverride None
:

9:
10: Options Indexes FollowSymLinks MultiViews
11: AllowOverride None

:

17:
18: AllowOverride None
19: Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
:

80: ErrorLog /var/log/apache2/error.log
84: LogLevel warn
87: ServerSignature EMail
:

In file: /etc/apache2/sites-enabled/rochesterflyingclub.com

2:
3: ServerName rochesterflyingclub.com
4: ServerAlias www.rochesterflyingclub.com
5: ServerAdmin webmaster@rochesterflyingclub.com
7: DocumentRoot /www/rochesterflyingclub.com/www
8:
9: Options FollowSymLinks
10: AllowOverride None
:

12:

13: Options Indexes FollowSymLinks MultiViews Includes
15: AllowOverride FileInfo AuthConfig Limit
:

20:
21: AllowOverride None
22: Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
:

27: ErrorLog /var/log/apache2/error.log
31: LogLevel warn
34: ServerSignature EMail

:


Answer



Either take :80 off the first or repeat it for all elements. I think the most specific address definition has precedence


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...