Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I want to have to addresses mydomain.com ( www.mydomain.com ) that points to /var/www/html/mydomain and webmail.mydomain.com that points to /var/www/html/webmail I have one IP so I am using name based ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2004
    Posts
    34

    **Resolved** Apache virtual Server problem


    I want to have to addresses

    mydomain.com (www.mydomain.com) that points to /var/www/html/mydomain

    and

    webmail.mydomain.com that points to /var/www/html/webmail

    I have one IP so I am using name based

    I tried this:

    <VirtualHost *:80>
    ServerName webmail.mydomain.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/webmail
    </VirtualHost>
    <VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/mydomain
    </VirtualHost>

    The first part work I can view my webmail but when I browse to mydomain.com or www.mydomain.com it goes to the webmail folder instead of the mydomain folder.

    Please Help

  2. #2
    Just Joined!
    Join Date
    Jan 2005
    Posts
    30
    Try this config:


    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerName webmail.mydomain.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/webmail
    </VirtualHost>
    <VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/mydomain
    </VirtualHost>

    PS: I add "NameVirtualHost *:80"

  3. #3
    Just Joined!
    Join Date
    Oct 2004
    Posts
    34
    Thanks, i forgot to uncomment that line.

  4. #4
    Linux Engineer adrenaline's Avatar
    Join Date
    Aug 2004
    Location
    Seattle, Washington
    Posts
    1,058
    I want to hi-jack this thread because it is along the lines of my question. I am running my own DNS and I have a webserver that hosting multiple websites. I am paying a lot for IP's and If I do the virtual option as above. Do I make all of my sites the same IP in my DNS?
    To clarify would I have to make all of the websites IP addresses the Ip of the webserver?
    Does this make sense?
    Mike
    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

  5. #5
    Just Joined!
    Join Date
    Jan 2005
    Posts
    30
    "Do I make all of my sites the same IP in my DNS? "
    YES and it's works beautifull.

    I recommand you that the first VirtualHost will be a default one that says
    that this webserver hosts multiple websites because if someone will use
    the IP of the webserver he will get the first VirtualHost.

  6. #6
    Linux Engineer adrenaline's Avatar
    Join Date
    Aug 2004
    Location
    Seattle, Washington
    Posts
    1,058
    Quote Originally Posted by murphy_young
    if someone will use
    the IP of the webserver he will get the first VirtualHost.
    I don't understand this statement. Do you mean if they enter the IP instead of the name?
    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

  7. #7
    Just Joined!
    Join Date
    Jan 2005
    Posts
    30
    "Do you mean if they enter the IP instead of the name?"

    YES

    Let's say for exemple, that you have 20 VirtualHost (web site):

    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerName www.site1.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/site1
    </VirtualHost>

    <VirtualHost *:80>
    ServerName www.site2.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/site2
    </VirtualHost>

    <VirtualHost *:80>
    ServerName www.site3.com
    DirectoryIndex index.php
    DocumentRoot /var/www/html/site3
    </VirtualHost>

    <VirtualHos . . .

    Now the IP of the web server is 1.1.1.1

    If some one will enter the IP 1.1.1.1 instead of site3 or site2 or site1 ...
    he will get the first VirtualHost on the list, and in this example this is
    site1. So if for example you are a webhosting company, the first
    VirtualHost will be a default page, Not a customer web site, it can be a
    web page for example only with your company logo.

  8. #8
    Linux Engineer adrenaline's Avatar
    Join Date
    Aug 2004
    Location
    Seattle, Washington
    Posts
    1,058
    thanks, I am going to do that tonight when I get home. I will give back some IP's and save money yay!
    I will let you know how it goes.
    Thanks again
    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

  9. #9
    Just Joined!
    Join Date
    Jan 2005
    Posts
    30
    " I will let you know how it goes. "
    Well, did you success?

  10. #10
    Linux Engineer adrenaline's Avatar
    Join Date
    Aug 2004
    Location
    Seattle, Washington
    Posts
    1,058
    Thanks for checking up on me but as luck would have it i had to work real late last night and didn't get a chance to get to it and tonight I start back on school I will definitely get to it this weekend.

    I will keep you posted for sure
    Thanks again,
    Mike
    Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
    -- Linus Torvalds

Page 1 of 2 1 2 LastLast

Posting Permissions

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