Results 1 to 9 of 9

Thread: Setting up multiple Virtual Hosts

  1. #1
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default Setting up multiple Virtual Hosts

    I have Apache2 installed - and I can access LocalHost fine, But I want multiple "localhosts".

    I think it's called a "virtual host". I don't have/want a domain, just a local server. So if I go to http://someserver/ it'll load like if I put in http://localhost/.

    I've looked into it, and all the articles I read either I didn't get, or didn't work...

    Anyone help?

    Edit: I'm pretty comfortable with terminal (GNOME) if anything is needed to be done in terminal


    Thanks,
    X96 WD
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    maybe http://ubuntuforums.org/showthread.php?t=126298 or http://www.google.com/search?q=multi...=Google+Search ? It involves editing apache/conf/extra/httpd-vhosts.conf . you also have to uncomment a line in httpd.conf from:
    Code:
    # Virtual hosts
    #Include conf/extra/httpd-vhosts.conf
    to
    Code:
    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    I;m following this: http://httpd.apache.org/docs/1.3/vhosts/name-based.html, but can't get it to work. Apache isn't giving me errors, but it won't work. I've added the following into httpd.conf:
    Code:
        NameVirtualHost *
    
        <VirtualHost *>
        ServerName main-server
        DocumentRoot /home/user/public_html
        </VirtualHost>
    
        <VirtualHost *>
        ServerName x96design
        DocumentRoot /home/user/Documents/WebDesign/x96webdesign
        </VirtualHost>
    Edit: I can access http://localhost, but none of the extra virtual hosts I specified in the httpd.conf file.


    Any suggestions?

    // X \\
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  4. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    here is what i have been using:
    Code:
    NameVirtualHost *:80
    
    #
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for all requests that do not
    # match a ServerName or ServerAlias in any <VirtualHost> block.
    #
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot "c:/wamp/www"
        ServerName localhost
        ErrorLog "logs/localhost-error.log"
        CustomLog "logs/localhost-access.log" common
    </VirtualHost>
    and you would just change what you need
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  5. #5
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    It works perfectly for one location, but what do you have to do in order for the second one to work? How do I assign the second Document Root a different server name? Because no matter what name I put in, it won't work (even after restarting apache)...

    I guess I could just change the config file every time I wanted to test a different site (change the document root)

    // X96 \\
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    If you are doing this locally, you need to have a DNS server local as well to process the domain requests. Otherwise, each host pointing to your server ip will appear as though you typed in localhost.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    So how do I set up a DNS server?

    // X \\
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    it depends. If you have a linux box, you could use "Bind"; or if you have a Windows Server (Win 2k - 2k8) you could use the built in DNS. If you have windows XP or later (not sure about before XP), you may be able to edit your hosts file (\Windows\system32\drivers\etc\hosts) to insert an entry to point to that domain; however, I really don't have a lot of experience with this. The following link may help you further though:
    http://vlaurie.com/computers2/Articles/hosts.htm

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    I'm using a Linux box, Ubuntu 9.04 to be precise... I'll look into Bind...

    Edit: I think I'll stick with just one Domain for now... I'll look into it again once I learn a bit more about all this DNS and stuff.


    // X \\
    Last edited by X96 Web Design; 05-05-2009 at 03:09 AM.
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

Bookmarks

Posting Permissions

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