-1

I am trying to configure a new vhost in apache under Amazon Linux. The new site should respond to newsite.mydomain.com, while the existing site should respond to all other requests to mydomain.com. This is what my vhosts.conf looks like:

NameVirtualHost *:80

<VirtualHost *:80>
        ServerAdmin support@mydomain.com
        DocumentRoot /var/www/public/newsite.mydomain.com/html
        ServerName newsite.mydomain.com
        ErrorLog  /var/www/public/newsite.mydomain.com/logs/error.log
        CustomLog  /var/www/public/newsite.mydomain.com/logs/access.log common
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin support@mydomain.com
        DocumentRoot /var/www/html
        ServerName *.mydomain.com
        ServerAlias *.myotherdomain.com
        ErrorLog logs/error_log
</VirtualHost>

With this config, I can get to the new site just fine, but the existing site using the wildcards breaks, it brings up the default apache page.

What am I doing wrong?

Thanks for any help,

Warren

2 Answers2

1

You should use the fully qualified domain name in the ServerName directive (apache doc) for the second vHost, and not use wildcards in it:

ServerName mydomain.com

ServerAlias *.mydomain.com
ServerAlias myotherdomain.com
ServerAlias *.myotherdomain.com

Hope this brings you further

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
Zimmi
  • 1,071
  • 7
  • 11
0

I think you're missing following:

[alexus@wcmisdlin02 ~]$ grep ^NameVirtualHost /etc/httpd/conf/httpd.conf 
NameVirtualHost *:80
[alexus@wcmisdlin02 ~]$ 

make sure you uncomment this line and restart httpd.

alexus
  • 13,112
  • 32
  • 117
  • 174