We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Setting up Virtual Hosts problems

spud17
spud17 Posts: 4,441 Forumite
Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
Probably not the best day to post this.:)

But I've spent hours trying to figure it out.

First off, all I know about this I've taught myself over the last few months, so indulge me.

I have a domain registered with 123reg.

I run a simple website from a spare PC, using XP and wamp.

Must admit, I found it easier to set up than I'd imagined.:)

I now want to add a sub domain, i.e. sub.xxxx.co.uk

I've read loads of articles and worked through examples, but it never quite works.

It works properly on the server, but not from anywhere else, if I use LAN address I only get the main page, the sub returns, can't find server.

e.g. used http://guides.jlbn.net/setvh/setvh1.html

Any helpful suggestions where I should be looking for the problem?

vhosts looks like this
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.xxxx.co.uk
ServerAlias xxxx.co.uk xxxx
DocumentRoot C:/wamp/www/xxxx
ErrorLog "C:/wamp/www/xxxx/logs/error.log"
CustomLog "C:/wamp/www/xxxx/logs/access.log" common

</VirtualHost>

<VirtualHost *:80>

ServerName sub.xxxx.co.uk
ServerAlias sub
DocumentRoot C:/wamp/www/sub
ErrorLog "C:/wamp/www/sub/logs/error.log"
CustomLog "C:/wamp/www/sub/logs/access.log" common

</VirtualHost>

<VirtualHost *:80>

ServerName localhost
DocumentRoot C:/wamp/www
ErrorLog "C:/wamp/www/logs/error.log"
CustomLog "C:/wamp/www/logs/access.log" common

</VirtualHost>
Move along, nothing to see.
«1

Comments

  • tronator
    tronator Posts: 2,859 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Your DNS needs to know where to find the subdomain. Or just put

    x.x.x.x sub.xxxx.co.uk

    in your host file
  • spud17
    spud17 Posts: 4,441 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    tronator wrote: »
    Your DNS needs to know where to find the subdomain. Or just put

    x.x.x.x sub.xxxx.co.uk

    in your host file

    I did wonder about that, but read that you don't need to alter DNS, because by using 'name based hosts', Apache directs the request to the correct page.

    Just to add, this is not running on the server, but on a cobbled together PC, so if I trash wamp, I just reinstall.

    I was logging everything, but have altered so much that I've lost track.:D
    The best I got was, the Apache index with the 2 home pages, but it didn't matter which site you tried to access.

    I'll definitely try your suggestion.
    Move along, nothing to see.
  • tronator
    tronator Posts: 2,859 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    spud17 wrote: »
    I did wonder about that, but read that you don't need to alter DNS, because by using 'name based hosts', Apache directs the request to the correct page.

    These are two different things. Apache knows what to do with this request, but the computer you try to access the (sub)domain from needs to resolve the (sub)domain to an IP. Otherwise it doesn't know what web server to access.

    Other question, do you want to access this subdomain from the Internet later? Then you need to setup the subdomain at 123-reg. I think you have a few free ones included. Otherwise use OpenDNS and change the DNS at 123-reg to the OpenDNS ones.
  • spud17
    spud17 Posts: 4,441 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    Other question, do you want to access this subdomain from the Internet later?

    Yes I will in the future, it is becoming clearer. I'll have to check, but I don't think 123 reg do free subdomains.
    I'll also check out OpenDNS, but it will be when I get time, this is only a hobby, so time is not important, off to party now, thanks.
    Move along, nothing to see.
  • Mr_Oink
    Mr_Oink Posts: 1,012 Forumite
    Tronator is spot on. You need a way to resolve 'sub' to the IP running Apache so that the request is rooted. Once it gets to the right machine Apache will look at the 'host' header and steer it to the correct virtual host.

    I guess you are not running your own DNS server, so it's a case of add 'sub' into your hosts file. This is usually %SystemRoot%\system32\drivers\etc\hosts

    As for the subdomain, yes 123reg charge for this (quite why I'm not sure, but I guess they have to make a living). If you were running your own DNS server it would cost you diddly squat to set it up, but that's not something I would recommend for something you are 'mucking about' with - if you forgive the use of that phrase.

    http://www.123-support.co.uk/support/answers/how-do-i-buy-a-subdomain-278/
  • spud17
    spud17 Posts: 4,441 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    edited 13 June 2010 at 11:28AM
    Yes I'm just 'mucking about', perfect description.

    It's going to be on hold for a while, other things to do.

    Just had a thought, what about using my Free DynDNS account for the sub?
    Move along, nothing to see.
  • Mr_Oink
    Mr_Oink Posts: 1,012 Forumite
    Not sure how that would pan out. You would need to configure an A record for the subdomain and I don't *think* you can do that with a free DynDNS account. What you could do is set us a DynDNS host to point to your apache and add the host header it comes in with to the alias and achieve more or less the same thing :-)
  • tronator
    tronator Posts: 2,859 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    spud17 wrote: »
    Just had athought, what about using my Free DynDNS account for the sub?

    I think you can't do it with the free account, you'll need "DynDNS Custom". OpenDNS will do it for you for free...
  • spud17
    spud17 Posts: 4,441 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    Just had athought, what about using my Free DynDNS account for the sub?
    Just had to give it a go, :D

    Changed all the 'sub' references entries on the sever to something more appropriate, didn't have to, but makes thing easier in this case.

    Went to DynDNS, put in details, all works perfectly.

    13yo nephew now chuffed with his own web space, especially as the address ends in kicks-a**.net.
    His mother (my sister) not so impressed, result. :eek::D
    Move along, nothing to see.
  • Mr_Oink
    Mr_Oink Posts: 1,012 Forumite
    Fantastic - and technically a money saving tip too ;-)
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.5K Banking & Borrowing
  • 253.7K Reduce Debt & Boost Income
  • 454.5K Spending & Discounts
  • 245.5K Work, Benefits & Business
  • 601.5K Mortgages, Homes & Bills
  • 177.6K Life & Family
  • 259.5K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.