Results 1 to 6 of 6

Thread: Apache Name-Based Virtual Host Not Pointing

  1. #1
    Join Date
    Sep 2007
    Location
    USA
    Beans
    329
    Distro
    Ubuntu 13.10 Saucy Salamander

    Apache Name-Based Virtual Host Not Pointing

    I have a typical setup on my server with two Virtual Hosts. Here is an example of my configuration:

    Ubuntu 13.04 (x64)
    Apache 2.2.22

    Listen 80
    <VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot /share/websites/localhost/example.com
    # Other directives here
    </VirtualHost>

    <VirtualHost *:80>
    ServerName d8.example.com
    DocumentRoot /share/websites/localhost/d8.example.com

    # Other directives here
    </VirtualHost>


    My problem is that d8.example.com doesn't come up when I bring up the site. Instead, www.example.com comes up in it's place. I understand precedence here but the site is being called directly locally so I'm confused why Apache isn't directing traffic to the right place. Any ideas how what's wrong or how I can troubleshoot this?

  2. #2
    Join Date
    Mar 2006
    Location
    Arlington VA USA
    Beans
    430
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Apache Name-Based Virtual Host Not Pointing

    Be sure to re-start Apache after setting up the config file.

  3. #3
    Join Date
    Sep 2007
    Location
    USA
    Beans
    329
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Apache Name-Based Virtual Host Not Pointing

    Thanks for the advice...it is good. However, I think I've restarted about 20 times now. I restart after every configuration change.

  4. #4
    Join Date
    Apr 2006
    Beans
    Hidden!

    Re: Apache Name-Based Virtual Host Not Pointing

    Quote Originally Posted by mastermindg View Post
    I have a typical setup on my server with two Virtual Hosts. Here is an example of my configuration:

    Ubuntu 13.04 (x64)
    Apache 2.2.22

    Listen 80
    <VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot /share/websites/localhost/example.com
    # Other directives here
    </VirtualHost>

    <VirtualHost *:80>
    ServerName d8.example.com
    DocumentRoot /share/websites/localhost/d8.example.com

    # Other directives here
    </VirtualHost>


    My problem is that d8.example.com doesn't come up when I bring up the site. Instead, www.example.com comes up in it's place. I understand precedence here but the site is being called directly locally so I'm confused why Apache isn't directing traffic to the right place. Any ideas how what's wrong or how I can troubleshoot this?
    What does the logs say?
    /var/log/apache2/error.log
    You may find a clue there. Make sure you crtl+f5 when refreshing in the browser too.

  5. #5
    Join Date
    Aug 2009
    Location
    Makati City, Philippines
    Beans
    1,991
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Apache Name-Based Virtual Host Not Pointing

    Here's my 3 domain setup and the contents of the /etc/apache2/sites-available/default
    And take note the 1st line. It didn't work if it is not there.
    Code:
    NameVirtualHost *
    
    <VirtualHost *>
    
        ServerName www.domain1.net
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/www.domain1.net/
        <Directory />
            Options FollowSymLinks
            AllowOverride None
        </Directory>
        <Directory /var/www/www.domain1.net/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
        </Directory>
    
    </VirtualHost>
    
    <VirtualHost *>
    
            ServerName www.domain2.ph
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/www.domain2.ph/
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/www.domain2.ph/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
           
    </VirtualHost>
    
    <VirtualHost *>
    
            ServerName www.domain3.com
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/domain3.com/
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/domain3.com/>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
     
    </VirtualHost>
    You know what solved my problems? GOOGLE Searches!
    The best Ubuntu derivative: Linux Mint
    Relax. Head to the Community Cafe
    The Philippine Team

  6. #6
    Join Date
    Sep 2007
    Location
    USA
    Beans
    329
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Apache Name-Based Virtual Host Not Pointing

    Quote Originally Posted by nerdtron View Post
    Here's my 3 domain setup and the contents of the /etc/apache2/sites-available/default
    And take note the 1st line. It didn't work if it is not there.
    Code:
    NameVirtualHost *
    That did it! Thanks a bunch nerdtron.

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
  •