Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

  1. #1
    Join Date
    Feb 2009
    Location
    Texas
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Hello forum friends.

    Need a little help with my Apache configuration. I've registered two websites on internet (domain registration) The idea is use my webserver to hosts both sites with my only public IP. I already change the A host record for my sites to point to my home webserver. But no matter what, the 2nd site is not loading, I'm always seeing the 1st default webpage. I'll describe my configuration a bit, just changing the real url...

    The two folders that hosts my web content:
    - /var/wwww ---> for site www.fake1.com
    - /var/joe ---> for site www.fake2.com

    I have NOT changed /etc/apache2/apache2.conf ... no changes here regarding my virtualhosts.

    Inside /etc/apache2/sites-available/ you will find "default". I use default for my virtual hosts, something like this

    Code:
    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
    
            DocumentRoot /var/www
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    .
    .
    .
    </VirtualHost>
    
    
    <VirtualHost *:80>
            ServerName fake2.com
            ServerAlias www.fake2.com
    
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/joe/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    </VirtualHost>
    I think is something like that ... did not copy paste everything in order to simplify. Problem is that no matter what, if I use www.fake2.com on my browser, it will display the default page for www.fake1.com instead.

    How can I make it work for both of my websites using my only public IP? Both domain names have been registered. And I know A records are pointing to my own webserver because wwww.fake1.com and www.fake2.com both displays something from internet: the default web page content.
    Last edited by jocampo; August 25th, 2009 at 02:05 PM.

  2. #2
    Join Date
    Dec 2006
    Location
    Chicago
    Beans
    3,839

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    That looks like that configuration should work. Are you sure your browser isn't displaying a cached page? Try running this command:
    Code:
    echo -e "GET / HTTP/1.0\nHost: fake2.com\n"|nc fake2.com 80

  3. #3
    Join Date
    May 2008
    Location
    Puerto Rico
    Beans
    65
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Kk, I'm not a guru, but for what I've looked so far in your post I saw 2 things that intrigued me a bit:

    1. One of the sites seems to be the "default" enabled site. Probably that's the one you can see in the browser w/o problems. Need to make sure of having both sites enabled, and, I might be wrong but I think there's a chance that you might have to dissable the default site. I hope someone can add to this.

    2. As far as I know, everything intended to be published has to be inside the /var/www directory (actually, popular opinion is that it's best to add subfolders for websites under the /www, as www is owned by the root user). You already have 1 site there, but the other is outside, in /var/joe ? I can see that path is defined in the config file but I've never seen it like that (in my rather short Ubuntu life), not sure is it should work as it is.

    Again, not a guru here, but almost sure your problem could be somewhere around these issues. Cheers...
    - "We are not because of our skills, but because of our choices" -- Dumbledore, in "The Prisoner of Azkaban"
    - "Say it like if I was 8 years old" -- Denzel Washington, in "Philadelphia"

  4. #4
    Join Date
    Feb 2009
    Location
    Texas
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Quote Originally Posted by Kolipoki View Post
    Kk, I'm not a guru, but for what I've looked so far in your post I saw 2 things that intrigued me a bit:

    1. One of the sites seems to be the "default" enabled site. Probably that's the one you can see in the browser w/o problems. Need to make sure of having both sites enabled, and, I might be wrong but I think there's a chance that you might have to dissable the default site. I hope someone can add to this.

    2. As far as I know, everything intended to be published has to be inside the /var/www directory (actually, popular opinion is that it's best to add subfolders for websites under the /www, as www is owned by the root user). You already have 1 site there, but the other is outside, in /var/joe ? I can see that path is defined in the config file but I've never seen it like that (in my rather short Ubuntu life), not sure is it should work as it is.

    Again, not a guru here, but almost sure your problem could be somewhere around these issues. Cheers...
    Hi

    I lived in Puerto Rico for 9 years ... nice place...

    Welcome to the forum and Ubuntu life, I love both! lol ... you can keep your web content in different folders as long as you specify that on the sites-available files configuration, so when apache.conf calls it, will know where to find the files. And yes, /var/wwww and /var/joe are owned by root and have same permissions. In fact, I checked it putting default in disable and enable the other one ... you can retrieve the information from there.

    Both sites are in enable state ... getting no errors but when you go to internet, content for default or 1st site is displayed, not the second one.

  5. #5
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Hi,
    Why haven't you set a document root for the 2nd virtual host.

    And why no ServerName/ServerAlias for the 1st?

  6. #6
    Join Date
    Dec 2006
    Location
    Chicago
    Beans
    3,839

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Quote Originally Posted by DaithiF View Post
    Hi,
    Why haven't you set a document root for the 2nd virtual host.

    And why no ServerName/ServerAlias for the 1st?
    Of course! You set the options for /var/joe, but never made it DocumentRoot. I can't believe I missed that. You said that wasn't an exact copy-and-paste, though, so do you have DocumentRoot in your second vhost configuration?

    I don't think the ServerName or ServerAlias is required for the first (default) vhost as it is used for any hostname that isn't configured with another vhost.

  7. #7
    Join Date
    Feb 2009
    Location
    Texas
    Beans
    Hidden!
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Now I'm confused...

    But ok, let me ask this. What changes/options do I need to do at

    /etc/apache2/apache2.conf ?

    Can i put all my virtual host directives inside /etc/apache2/sites-available/default file? or should I create another file like /etc/apache2/sites-available/site2

    I'm at work, but I can play a little bit now on the files remotely and check again

  8. #8
    Join Date
    Aug 2009
    Beans
    15
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    There are instructions in the Ubuntu Forums website somewhere about setting up Virtual Hosts under Apatche2. Due to the fact that Virtual hosting is done differently under Ubuntu than any other distro the Apatche docs aren't too helpfull but tI think their is also a specific section addresssing it now.

    I had a similar issue and what I had to do was put the ServerName *:80 in the relevant section (nr the bottom) in the httpd.conf file, then take that value out of all the virtual host conf files.

    As this one version is more modular, you may find it easier to create a website1.conf, website2.conf in your sites-available folder, then use a2ensite for each to symlink the files to sites-enabled.

    I can't find the relative info for you at the mo, but I hope that points you in the right direction.

  9. #9
    Join Date
    Dec 2006
    Location
    Chicago
    Beans
    3,839

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Quote Originally Posted by jocampo View Post
    Now I'm confused...

    But ok, let me ask this. What changes/options do I need to do at

    /etc/apache2/apache2.conf ?

    Can i put all my virtual host directives inside /etc/apache2/sites-available/default file? or should I create another file like /etc/apache2/sites-available/site2

    I'm at work, but I can play a little bit now on the files remotely and check again
    Generally, there is one vhost configuration per file. Once you create a new "site", you would need to enable it (sudo a2ensite site2). Putting multiple vhost configurations in /etc/apache2/sites-available/default would work, but isn't really the standard way of doing things in ubuntu.

    You shouldn't edit apache2.conf to configure virtual hosts (sites). It is only for global configurations unrelated to any module or listening configuration. Also, you shouldn't edit httpd.conf for anything in ubuntu (I've seen it suggested in other threads).

  10. #10
    Join Date
    Dec 2006
    Location
    Chicago
    Beans
    3,839

    Re: Help with Apache VirtualHosts. Using 1 IP for two sites. One is not loading

    Quote Originally Posted by scottybwoy View Post
    I had a similar issue and what I had to do was put the ServerName *:80 in the relevant section (nr the bottom) in the httpd.conf file, then take that value out of all the virtual host conf files.
    I believe you are actually referring to the NameVirtualHost directive, correct? I think it used to be at the top of the default site configuration, but it has been moved to "/etc/apache2/ports.conf" in recent releases. If you have "NameVirtualHost *:80" used more than once anywhere in your configuration, I think that would cause a problem.

Page 1 of 3 123 LastLast

Tags for this Thread

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
  •