Find the answer to your Linux question:
Results 1 to 9 of 9
I would like to configure my Debian server to take a give domain name ive purchased, and use my single IP address in my house, to send multiple domains to... ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Posts
    35

    Virtual Hosts (Apache)


    I would like to configure my Debian server to take a give domain name ive purchased, and use my single IP address in my house, to send multiple domains to...

    example

    thegoshem.com 12.34.56.78 /var/www/

    whatever.com 12.34.56.78 /var/www/whatever/

    moist-towlette.com 12.34.56.78 /var/www/towlette/

    ive found out that i need to use virtual hosts, i guess my question is what should my config look like?


    NameVirtualHost *:80
    NameVirtualHost *

    #<VirtualHost
    #
    #the example
    #one goes here
    #
    #
    #</virtualhost>
    #
    #

    <virtualhost *>
    ServerAdmin admin@thegoshem.com
    DocumentRoot /var/www/
    ServerName thegoshem.com
    ErrorLog logs/thegoshem.com-error.log
    CustomLogs logs/thegoshem.com-access.log common
    <virtualhost>

    <virtualhost *>
    ServerAdmin admin@whatever.com
    DocumentRoot /var/www/whatever/
    ServerName whatever.com
    ErrorLog logs/whatever.com-error.log
    CustomLogs logs/whatever.com-access.log common
    <virtualhost>

    <virtualhost *>
    ServerAdmin admin@moist-towlette.com
    DocumentRoot /var/www/moist-towlette/
    ServerName moist-towlette.com
    ErrorLog logs/moist-towlette.com-error.log
    CustomLogs logs/moist-towlette.com-access.log common
    <virtualhost>

    #<VirtualHost _default_:*>
    #</VirtualHost>

    is that how those are supposed to look?

  2. #2
    Just Joined!
    Join Date
    Apr 2005
    Posts
    40
    Your right. This is my example of conf file I use for my webmail. Apache has many features, it takes only couple of minutes (hours) to go through it


    <VirtualHost 81.0.234.20:80>
    ServerName mail.net-links.cz
    ServerAlias mail.*
    ServerAdmin postmaster@net-links.cz
    DocumentRoot /var/www/htdocs/webmail
    </VirtualHost>

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Posts
    35
    <VirtualHost *>
    ServerAdmin dave@thegoshem.com
    DocumentRoot /www/dave
    ServerName dpsflashs.ath.cx
    ErrorLog /var/www/log/apache/error.log
    CustomLog /var/www/log/apache/access.log common
    </VirtualHost>

    <VirtualHost _default_:*>
    ServerAdmin admin@thegoshem.com
    DocumentRoot /www
    ServerName thegoshem.com
    ErrorLog /var/www/log/apache/error.log
    CustomLog /var/www/log/apache/access.log common
    </VirtualHost>


    thats in my config, but when i load dpsflashs.ath.cx for some reason it still goes to my main page when i tshould be going to /www/dave/ not /www right????? i dont get it, me confused

  4. #4
    Just Joined!
    Join Date
    Jan 2005
    Location
    UK
    Posts
    77
    i would try something like this:

    <VirtualHost thegoshem.com:80>
    ServerAdmin dave@thegoshem.com
    DocumentRoot /www/dave
    ServerName thegoshem.com:80
    ErrorLog /var/www/log/apache/error.log
    CustomLog /var/www/log/apache/access.log common
    </VirtualHost>

    Also, a good tip is to have different log files for each of your virtual hosts. This way you can split all the requests and see exactly where the traffic is going without looking too hard.

  5. #5
    Just Joined!
    Join Date
    Apr 2005
    Posts
    35
    that didnt work, maybe im just explaining it all wrong... ill explain it again better maybe

    i have one linux server with the ip lets say is 192.168.1.5 or 65.43.238.61

    i went and bought www.thegoshem.com and had it redirected to 65.43.238.61
    and im using just the domain from netfirms. When it loads up, it loads the default or /var/www

    i want to purchase another .com, lets say www.dpsflashs.com and make it redirect to /var/www/dave at ip address 65.43.238.61 (same one)

    however, netfirms only allows me to enter the IP address, so it would load the default, everytime i change the virtual server, no matter what i do to it, it still loads the default.

    maybe im just not understanding it, i dont know, anymore help would be much appreciated.

  6. #6
    Just Joined!
    Join Date
    Apr 2005
    Posts
    1

    Virtual Host

    I'm a newbie, but I belive your httpd.conf file should have something similar to this for each virtual host when using the same IP address. I would expect that a pro could show me some mistakes with this, but I currently have two virtual hosts using this method and it is working.


    <VirtualHost 192.168.1.5>
    DocumentRoot */var/www/thegoshem*
    ServerName thegoshem.com
    <Directory */var/www/thegoshem/*>
    allow from all
    Options +Indexes
    </Directory>
    ServerAlias *.thegoshem.com
    HostNameLookups on
    ServerAdmin admin@thegoshem.com
    ErrorLog logs/thegoshem.com-error.log
    CustomLogs logs/thegoshem.com-access.log common
    </VirtualHost>

    Note the first and last lines differ from what you posted on 4/1
    1. May be case sensative (I treat everything in Linux to be case sensative)
    2. Must have your local IP address in first line as shown
    3. Must end each virtual host using the / character.


    hope this helps
    Bill

    P.S. I use webmin - it helps when you're a newbie.

  7. #7
    Just Joined!
    Join Date
    Apr 2005
    Posts
    62
    Quote Originally Posted by thegoshem
    that didnt work, maybe im just explaining it all wrong... ill explain it again better maybe

    i have one linux server with the ip lets say is 192.168.1.5 or 65.43.238.61

    i went and bought www.thegoshem.com and had it redirected to 65.43.238.61
    and im using just the domain from netfirms. When it loads up, it loads the default or /var/www

    i want to purchase another .com, lets say www.dpsflashs.com and make it redirect to /var/www/dave at ip address 65.43.238.61 (same one)

    however, netfirms only allows me to enter the IP address, so it would load the default, everytime i change the virtual server, no matter what i do to it, it still loads the default.

    maybe im just not understanding it, i dont know, anymore help would be much appreciated.

    try to comment your main DocumentRoot and the <directory></directory> related to it
    then add

    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerName thegoshem.org
    DocumentRoot "/var/www/main"
    </VirtualHost>

    <VirtualHost *:80>
    ServerName yourseconddomain.org
    DocumentRoot "/whatever/www/2nddomain"
    </VirtualHost>

    It works on my apache, I commented those that I mentioned

  8. #8
    Linux Enthusiast
    Join Date
    Feb 2005
    Location
    SE, Stockholm
    Posts
    512
    Just as a side-note, you must re-start your http server after you have made changes into you config files as well. (Which of course you have done )

    Anyhow, as few other writes here has told you, it is case-sensitive all your configurations. And you must have a corresponding DNS entry in your DNS server for your virtual server as well.

    Code:
    NameVirtualHost 192.168.1.5&#58;80
    
    <VirtualHost>
    ServerName www.thegoshem.com
    DocumentRoot /www/thegoshem
    </VirtualHost>
    
    <VirtualHost>
    ServerName dpsflashs.ath.cx
    DocumentRoot /www/dave
    </VirtualHost>
    Would be the minimal configuration that you would need.
    Make sure that you do not have multiple entries for "NameVirtualHost" from any other included config-files.
    And it is always better to configure the exact IP that your HTTP server will answer on, I just have to make a guess that you do a NAT for your external/public IP into your HTTP servers IP? Thats why you shoudl configure the VirtualHosting as the Internal IP.
    And as you see from my example above, I have set your web-server document root directory to a sub-directory as well.

  9. #9
    Just Joined!
    Join Date
    Apr 2005
    Posts
    35
    i fixed it, i had the config all set right


    heres part i dont get
    i restarted apache... which should be fine right?
    well, it didnt work

    soooo, i restarted my server, and then it worked, seems as though any time i edit apache it has to reboot, doesnt make sense but who knows.

Posting Permissions

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