3

I'm trying to setup an Apache server with several virtual hosts (www.domain.com & store.domain.com), but for some reason, when I just have one of them enabled (store.domain.com) Apache redirects to the wrong document root (/var/www), which is apparently the default one. This is the virtual host configuration file for the one that's not redirecting correctly:

<VirtualHost *:80>
     ServerName store.domain.com
     ServerAdmin [email protected]
     DocumentRoot /var/www/store/public_html/
     ErrorLog /var/www/store/logs/error.log
     CustomLog /var/www/store/logs/access.log combined
</VirtualHost>

When I run the command apache2ctl -S I get the following:

Name or service not known: AH00547: Could not resolve host name *80 --ignoring!
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, 
using xxx.xxx.xxx.xxx. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
.... 

Looks like the key is on the first line of the previous error, but I can't figure out what's wrong.

When I have the following virtual host enabled, it works fine:

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName www.domain.com
     DocumentRoot /var/www/html/www/public_html/
     ErrorLog /var/www/html/www/logs/error.log
     CustomLog /var/www/html/www/logs/access.log combined
</VirtualHost>

When this last virtual host is enabled, store.domain.com redirects to www.domain.com

Any suggestions? Please let me know if you need any additional information.

2
  • Form the given error, it seems there may be a syntax error in the virtualhost conf file and the file is getting ignored. But from your post I can't see any. Can you check the file again and post the content? Also may try, apache2ctl configtest.
    – Diamond
    Mar 9, 2016 at 18:55
  • And also check listen.conf file for possible syntax error.
    – Diamond
    Mar 9, 2016 at 19:03

2 Answers 2

2

Apache ServerAlias

Try to add ServerAlias in addition to ServerName.

1

Name or service not known: AH00547: Could not resolve host name *80

Check through your configuration looking for *80.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .