Re: [Hampshire] Apache virtual hosts

Top Page

Reply to this message
Author: Stuart Sears
Date:  
To: stephen.davies, Hampshire LUG Discussion List
Subject: Re: [Hampshire] Apache virtual hosts
On 16/02/10 12:04, Stephen Davies wrote:
> Can anyone recommend a good reference/step-by-step guide for setting up
> the httpd.conf file so that virtual hosts work properly.
>
> I've done this a few times in the past but more by luck than judgement,
> I have gotten it to work. Now I really need to understand it once and
> for all and then document it properly.
>
> The thing I'm trying to do is setup a server where I have seperate urls
> for the following
>
>     wordpress
>     joomla
>     gallery2
>     general web site

>
> phpmyadmin must also work. using "http://localhost/phpMyAdmin"
>
> In the testing environment, I have created the DNS names in DynDns that
> all point to external facing IP address which get routed to the Linux
> server where all this will be hosted.
>
>
> The problems I'm having is that I can get to the server via a name such
> as myblog.homelinux.org but all I get is the default homepage even
> though I have used the DocumentRoot inside the VirtualHost option.
> This is all being added to an existing & live site so I want to test it
> all on another machine first.
>
> Here is the relevant bits of the httpd.conf
> (I'm using port 60163 for testing through my router)
>
> NameVirtualHost *:60163
>
> <VirtualHost *:60163>
>     DocumentRoot /var/www/html
> </VirtualHost>

>
> <VirtualHost 127.0.0.1:60163>
>     DocumentRoot /var/www/html
>     ServerName  localhost
> </VirtualHost>

>
> <VirtualHost myblog.homelinux.org:60163>
>
>     DocumentRoot  /data1/myblog/
>     ServerName myblog.homelinux.org
> </VirtualHost>


These are not working because only the first virtualhost container
matches your NameVirtualHost statement.
once you have this statement in your config, all content is served from
virtualhost containers matching *:60163
if none match, the first defined one is used.

rewrite them all to say
<VirtualHost *:60163>
    ServerName my.server.name
    DocumentRoot /path/to/data
</VirtualHost>


and hopefully all should be well.

Assuming that all your 'ServerName' hostnames resolve to your IP address.

regards,

Stuart

--
Stuart Sears RHCA etc.
"It's today!" said Piglet.
"My favourite day," said Pooh.