Link to home
Start Free TrialLog in
Avatar of kent3800
kent3800

asked on

Ubuntu Virtual host resolves to another domain's first alphabetical sub-domain instead of its own

I have two domains on a rackspace cloud: Dice.com and Dive.com. The DNS for both point to one IP address. I have A records for both on rackspace that point to the same IP address. I have multiple virtual hosts running for Dice.com including beta.Dice.com, ads.Dice.com, and of course www.Dice.com. But when I navigate a browser to Dive.com I get the files for beta.mousedice.com

I have created a Dive.com virtual host and pointed it to the correct files. I have also enabled the Dive.com site via a2ensite Dive.com and restarted Apache.

Why am I able to see all of the DICE sites and only have the one DIVE site show the beta.Dice.com site?

Of course, I changed the domain names for privacy.
Thanks
Here is my Dive.com virtual host:

<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin webmaster@dive.com
  ServerName  dive.com
  ServerAlias www.dive.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html
  DocumentRoot /home/kent/public_html/dive.com/html
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory "/home/kent/public_html/dive.com/html/">
                Order Deny,Allow
                AllowOverride All
        </Directory>

  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/kent/public_html/dive.com/log/error.log
  CustomLog /home/kent/public_html/dive.com/log/access.log combined

</VirtualHost>

Open in new window

Avatar of bplant
bplant

Is it possible that the vhost for dive.com isn't being included somehow? Easiest way to check is to intentionally add a syntax error into the dive.com vhost and see if apache reloads. If it does, then the dive.com vhost isn't being included.
Avatar of kent3800

ASKER

I added a typo in the directory root of the dive.com vhost but apache still reloads. What does that mean? Why is it not being included? It says it is one of the enabled sites.
Don't put the typo in one of values, put it in a keyword. I.e. Change DocumentRoot to DDDocumentRoot. Does it still reload then?
ASKER CERTIFIED SOLUTION
Avatar of pointerstop
pointerstop
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok. I've tried both things...

the misspelling of the keyword results in a broken reload -- meaning it is being read

Also, most of my config files are root:root but since the rest of the dice.com domains work does that still apply? Which config files are your referring to?


Using sudo /etc/init.d/apache2 reload -S results in options and ultimately a fail message? Apache2 still reloads though. What does that mean? I also ran:

dice /etc/apache2/sites-available: sudo /etc/init.d/apache2 reload -t -D DUMP_VHOSTS
 * Reloading web server config apache2

which reloaded fine

see code below... can you read anything into this?

Thanks again!
Misspelled Keyword:

dice /etc/apache2/sites-available: sudo /etc/init.d/apache2 reload
Syntax error on line 10 of /etc/apache2/sites-enabled/dive.com:
Invalid command 'DDDDocumentRoot', perhaps misspelled or defined by a module not included in the server configuration
   ...fail!

dice ~: sudo /etc/init.d/apache2 reload -S
 * Reloading web server config apache2                                                                                                                                                 Usage: /usr/sbin/apache2 [-D name] [-d directory] [-f file]
                         [-C "directive"] [-c "directive"]
                         [-k start|restart|graceful|graceful-stop|stop]
                         [-v] [-V] [-h] [-l] [-L] [-t] [-S] [-X]
Options:
  -D name            : define a name for use in <IfDefine name> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)
  -S                 : a synonym for -t -D DUMP_VHOSTS
  -t -D DUMP_MODULES : show all loaded modules
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  -X                 : debug mode (only one worker, do not detach)
                                                                         [fail]

Open in new window

Doesn't look like that worked to me!  I suspect because you're using "reload" rather than "restart" that it simply did nothing.

I didn't tell you to add -S to the normal service start, I said to run:

apache2ctl -S

It's nothing like the same thing.  It should give you something like this:
$ apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:*                    is a NameVirtualHost
         default server morgen (/etc/apache2/sites-enabled/000-default:3)
         port * namevhost morgen (/etc/apache2/sites-enabled/000-default:3)
         port * namevhost nagisa.pointerstop.ca (/etc/apache2/sites-enabled/nagisa:1)
         port * namevhost obis.pointerstop.ca (/etc/apache2/sites-enabled/obis:1)
         port * namevhost plonevdc.pointerstop.ca (/etc/apache2/sites-enabled/plonevdc:1)
         port * namevhost pydap.pointerstop.ca (/etc/apache2/sites-enabled/pydap:1)
         port * namevhost vdc.pointerstop.ca (/etc/apache2/sites-enabled/vdc:1)
Syntax OK


And really, it's a whole lot easier to trace other people's problems if they give us the actual configurations they have problems with.  What privacy issues really require you to change the domain names?  Domain names are about as public as things get on the Internet.
And no, it doesn't matter that the config files are owned by root - they just have to be readable by www-data.  
How about an NDA? You can handle my legal bills.

apache2ctl returns: command not found. Here is the example:

dice /: apache2ctl -S
-bash: apache2ctl: command not found

You are right about the reload/restart! My mistake. And running this only results in a [fail] with no stats:
/etc/init.d/apache2 restart -S
 * Restarting web server apache2    [fail]

the dive.com config file is readable by www-data and is -rw-r--r-- just like the dice.com config files.

Sorry to have misunderstood you before. This is my first Cloud server configuration and I very much appreciate your help! What actual configurations do you need? I'm only omitting one word in the name of the domain.... Would be happy to post configs you'll just have to trust me the the DNS is pointed right at this moFo...
How about an NDA?  Your client can't reasonably expect you to not disclose domain names - they're public record, once registered.   The problem with " I changed the domain names for privacy" is that as soon as you start changing anything we can't know for sure why your configuration doesn't work.  If you absolutely feel you have to do that, you should work out a configuration using munged values that still gives the same problem.  Most likely, in performing that exercise you find out why it didn't work in the first place.

You need to learn to use the basic Unix tools - if you can't find apache2ctl, "locate" it.  If locate doesn't work, make sure mlocate is installed - you should never be without it.  In any case, apache2ctl is in /usr/sbin, and should really be on your PATH.
copy that! Thanks. I most definitely need to learn the Unix Tools. Thanks for pointing me in the right direction.

The domains are privately registered under a different corporation.
Thanks again pointerstop for the suggestions and hand holding.

I found apache2ctl and have figured out how to use it and WILL be adding it to my system PATH.

I'm not even sure what I did but by using apache2ctl restart and then apache2ctl k- restart everything restarted just fine.

Thanks again for your help