+ Post New Thread
Results 1 to 9 of 9
Web Development Thread, Apache and virtual hosts in Coding and Web Development; Ok I have Apache running fine and I am setting up various things on the server. The problem is I ...
  1. #1

    TechMonkey's Avatar
    Join Date
    Dec 2005
    Location
    South East
    Posts
    3,299
    Thank Post
    226
    Thanked 412 Times in 305 Posts
    Rep Power
    163

    Apache and virtual hosts

    Ok I have Apache running fine and I am setting up various things on the server. The problem is I have set up virtual hosts and now seem to have to set up one for everything I install otherwise it just directs me to the first virtual host. Have I set something up wrong or is this just the way it is?

  2. #2
    smadison's Avatar
    Join Date
    Sep 2007
    Location
    UK
    Posts
    100
    Thank Post
    2
    Thanked 30 Times in 25 Posts
    Rep Power
    20
    Try looking here

  3. 2 Thanks to smadison:

    TechMonkey (7th August 2009), ZeroHour (7th August 2009)

  4. #3

    TechMonkey's Avatar
    Join Date
    Dec 2005
    Location
    South East
    Posts
    3,299
    Thank Post
    226
    Thanked 412 Times in 305 Posts
    Rep Power
    163
    It is amazing how many times you can look through something and miss what you need. I've looked at that doc at least twice and not seen what I needed until now.

    For future reference add:

    Code:
    <VirtualHost _default_:*>
    DocumentRoot /www/default
    </VirtualHost>
    to the virtual hosts file and all is well Huzzah.

  5. #4

    TechMonkey's Avatar
    Join Date
    Dec 2005
    Location
    South East
    Posts
    3,299
    Thank Post
    226
    Thanked 412 Times in 305 Posts
    Rep Power
    163
    Ok I lied, that just breaks everything. So I am back to square one, can't find anything in the virtual hosts docs. Any ideas?

  6. #5

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,647
    Thank Post
    932
    Thanked 1,342 Times in 820 Posts
    Blog Entries
    1
    Rep Power
    449
    I am kinda lost as to what your doing.
    What do you mean by every time you install something? e.g wha?

  7. #6


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,694
    Thank Post
    352
    Thanked 803 Times in 718 Posts
    Rep Power
    348
    My typical set up is as follows:

    vhosts.conf (because I like them all together and don't trust a2en/dis site)

    Default vhost at the top for ServerName mywebhost.com and ServerAlias www.mywebhost.com so stuff like www.mywebhost.com/forums /bugs /admin etc all 'just' work for anything I install.

    I then have separate name based vhosts if its on a single IP for bob.mywebhost.com and jane.mywebhost.com to an individual folder so they too can have bob.mywebhost.com/forums /bananas etc.

    If you want to see some configs / examples of what I have give me a shout.

  8. Thanks to kmount from:

    TechMonkey (7th August 2009)

  9. #7

    TechMonkey's Avatar
    Join Date
    Dec 2005
    Location
    South East
    Posts
    3,299
    Thank Post
    226
    Thanked 412 Times in 305 Posts
    Rep Power
    163
    Thanks kmount, I think that is what I need first, a default entry.

    ZH: I have my webserver on serverx. I have installed moodle and assigned it to a virtual host of moodle.server.com. After that any web app I have installed, such as joomla, I have had to add a virtual host and dns host to be able to get at it. I could no longer just go http://serverx/joomla. If I tried it would think /joomla was a folder under moodle.

    I'll try entering a default entry and see what I can see.

  10. #8

    TechMonkey's Avatar
    Join Date
    Dec 2005
    Location
    South East
    Posts
    3,299
    Thank Post
    226
    Thanked 412 Times in 305 Posts
    Rep Power
    163
    Yep that did it. It was what I thought the solution above should have done. I now have:
    Code:
    <VirtualHost *:80>
        DocumentRoot "{htdocs path}"
        ServerName {ipaddress}
    </VirtualHost>
    As my first virtual host so now anything that server hasn't been explicitly told about it will go to the normal IP address. & i tested it before rejoicing so it really seems to work!

  11. #9


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,694
    Thank Post
    352
    Thanked 803 Times in 718 Posts
    Rep Power
    348
    I tend to do mine similarly but rather than IP I use names.

    NameVirtualHost 1.2.3.4:80

    <VirtualHost 1.2.3.4:80>
    ServerAdmin postmaster@mysite.com
    DocumentRoot /home/mysite/www
    ServerName mysite.com
    ServerAlias www.mysite.com
    ErrorLog /home/mysite/logs/errorlog.txt-www
    CustomLog /home/mysite/logs/accesslog.txt-www common
    </VirtualHost>

    <VirtualHost 1.2.3.4:80>
    ServerAdmin postmaster@mysite.com
    DocumentRoot /home/mysite/forums
    ServerName forums.mysite.com
    ErrorLog /home/mysite/logs/errorlog.txt-forum
    CustomLog /home/mysite/logs/accesslog.txt-forum common
    </VirtualHost>

    <VirtualHost 1.2.3.4:80>
    ServerAdmin postmaster@mysite.com
    DocumentRoot /home/mysite/moodle
    ServerName moodle.mysite.com
    ErrorLog /home/mysite/logs/errorlog.txt-moodle
    CustomLog /home/mysite/logs/accesslog.txt-moodle common
    </VirtualHost>
    So anything that's not forums.mysite.com or moodle.mysite.com lands on the top vhost (mysite.com) so I can have mysite.com/images mysite.com/etc as well as having moodle.mysite.com/images being separate.

    The logfiles are a pretty good idea too if you're building something and want to review the logs in a localised environment rather than for the whole box.

SHARE:
+ Post New Thread

Similar Threads

  1. Running moodle and mahara on same linux server - OUCH virtual hosts
    By reggiep in forum Virtual Learning Platforms
    Replies: 1
    Last Post: 1st June 2009, 01:50 PM
  2. Thin Client \ Virtual Desktop \ Virtual Apps
    By gshaw in forum Thin Client and Virtual Machines
    Replies: 3
    Last Post: 17th December 2008, 06:04 PM
  3. Wildcards in Apache virtual server
    By FN-GM in forum How do you do....it?
    Replies: 1
    Last Post: 16th September 2008, 03:22 PM
  4. Virtual Apache Servers
    By FN-GM in forum How do you do....it?
    Replies: 6
    Last Post: 30th May 2008, 08:18 PM
  5. Apache Virtual Hosting
    By Steven in forum Wireless Networks
    Replies: 6
    Last Post: 25th May 2008, 11:27 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •