Url Apache?

Discussion in 'Server Operation' started by Boothkicker, Nov 23, 2006.

  1. Boothkicker

    Boothkicker New Member

    Hello all! I am new to forum and this if my first post. I know this is a great site so I decided to join in on the forums.

    Here is my problem.

    I am running a Debian Linux server (used perfect debian install howto) and apache web server. I have 2 web sites that I am serving.
    1: www.boothkicker.com and
    2. www.bristleridgeacademy.com

    boothkicker.com is my primary page and the first one I set up. When I go to the site with a web browser "www.boothkicker.com" appears in url box. But when i go to "www.bristleridgeacademy.com" the ip address and the folder for web page is shown in url box. How can I fix this so that when the page is visited, "www.bristleridgeacademy.com" is shown?

    In /etc/apache2/sites-enabled/000-default I have the following:

    <VirtualHost *>
    ServerName boothkicker.com
    ServerAdmin [email protected]
    #Local address no port
    DocumentRoot /home/cody/public_html
    #directory to launch from
    ServerName www.boothkicker.com
    #www.servername.com
    </VirtualHost>


    <VirtualHost *>
    ServerName bristleridgeacademy.com
    DocumentRoot /home/dak/public_html
    ServerName www.bristleridgeacademy.com
    </VirtualHost>

    Thank you for any help!!!
     
    Last edited: Nov 24, 2006
  2. falko

    falko Super Moderator Howtoforge Staff

    Please change it to

    Code:
    NameVirtualHost 1.2.3.4
    
    <VirtualHost 1.2.3.4>
            ServerName boothkicker.com
            ServerAdmin [email][email protected][/email]
             #Local address no port
            DocumentRoot /home/cody/public_html
             #directory to launch from
            ServerName [url]www.boothkicker.com[/url]
             #[url]www.servername.com[/url]
    </VirtualHost>
    
    
    <VirtualHost 1.2.3.4>
            ServerName bristleridgeacademy.com
           DocumentRoot /home/dak/public_html
            ServerName [url]www.bristleridgeacademy.com[/url]
    </VirtualHost>
    where 1.2.3.4 is your system's IP address (you must see it in the output of
    Code:
     ifconfig
    ). Restart Apache afterwards.
     
  3. Boothkicker

    Boothkicker New Member

    Thank you for your reply, falko.

    When I did as you instructed me, I received this after restarting apache:

    server1:/etc/apache2/sites-enabled# /etc/init.d/apache2 restart
    Forcing reload of web server: Apache2[Fri Nov 24 09:16:46 2006] [warn] VirtualHost 192.168.0.101:0 overlaps with VirtualHost 192.168.0.101:0, the first has precedence, perhaps you need a NameVirtualHost directive
    [Fri Nov 24 09:16:46 2006] [warn] VirtualHost 192.168.0.101:0 overlaps with VirtualHost 192.168.0.101:0, the first has precedence, perhaps you need a NameVirtualHost directive
    .

    Any suggestions? (Sorry, I'm a newb)
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Can you post your new configuration here? What's the output of
    Code:
    ifconfig
    ?
     
  5. Boothkicker

    Boothkicker New Member

    /etc/apache2/sites-enabled/000-default contains this text:
    NameVirtualHost 192.168.0.101

    <VirtualHost 192.168.0.101>
    ServerName boothkicker.com
    ServerAdmin [email protected]
    #Local address no port
    DocumentRoot /home/cody/public_html
    #directory to launch from
    ServerName www.boothkicker.com
    #www.servername.com
    </VirtualHost>



    <VirtualHost 192.168.0.101>
    ServerName bristleridgeacademy.com
    DocumentRoot /home/dak/public_html
    ServerName www.bristleridgeacademy.com
    </VirtualHost>



    #<VirtualHost *>
    # ServerName securitycontrol.biz
    # ServerAdmin [email protected]
    #Local address no port
    # DocumentRoot /home/sce/public_html
    #directory to launch from
    # ServerName www.securitycontrol.biz
    #www.servername.com
    #</VirtualHost>


    The last virtual host is another site that I'm trying to server, but I have some nameserver stuff I have to figure out for it. That is why it is commented out.


    And the output of ifconfig is:
    server1:~# ifconfig
    eth0 Link encap:Ethernet HWaddr 00:16:EC:56:92:95
    inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:515767 errors:0 dropped:0 overruns:0 frame:0
    TX packets:101214 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:153664537 (146.5 MiB) TX bytes:48598126 (46.3 MiB)
    Interrupt:11 Base address:0xe400

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:1470 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1470 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:237220 (231.6 KiB) TX bytes:237220 (231.6 KiB)

    Thank you
     
  6. falko

    falko Super Moderator Howtoforge Staff

    I'm sorry, you're on Apache2, so it must be
    Code:
    NameVirtualHost 1.2.3.4[B][COLOR="Red"]:80[/COLOR][/B]
    
    <VirtualHost 1.2.3.4[B][COLOR="Red"]:80[/COLOR][/B]>
            ServerName boothkicker.com
            ServerAdmin [email protected]
             #Local address no port
            DocumentRoot /home/cody/public_html
             #directory to launch from
            ServerName www.boothkicker.com
             #www.servername.com
    </VirtualHost>
    
    
    <VirtualHost 1.2.3.4[B][COLOR="Red"]:80[/COLOR][/B]>
            ServerName bristleridgeacademy.com
           DocumentRoot /home/dak/public_html
            ServerName www.bristleridgeacademy.com
    </VirtualHost>
     
  7. Boothkicker

    Boothkicker New Member

    I added ":80" to the three ip addresses but it still changes to the ip address when you go to the address: www.bristleridgeacademy.com

    I purchases the domains through godaddy.com. I set the domain forwarding to 70.115.60.162/~dak. Is that what it should be set at for the above address? That is where the pages are stored.
     
    Last edited: Nov 26, 2006
  8. falko

    falko Super Moderator Howtoforge Staff

    Do not forward the domain because then name-based vhosts don't work. You must point the DNS records of the domain directly to your server.
     
  9. Boothkicker

    Boothkicker New Member

    Okay, I got it to somewhat work now. When you go to www.bristleridgeacademy.com the correct url is shown, but if you go to bristleridgeacademy.com (without www) it is directed to my boothkicker page but bristleridgeacademy.com is shown for url.

    How do I configure it so that bristleridgeacademy.com is directed to correct page?
     
  10. falko

    falko Super Moderator Howtoforge Staff

    Add a ServerAlias line to the vhost, e.g. like this:

    Code:
    <VirtualHost 1.2.3.4:80>
           DocumentRoot /home/dak/public_html
            ServerName www.bristleridgeacademy.com
            [B][COLOR="Red"]ServerAlias bristleridgeacademy.com[/COLOR][/B]
    </VirtualHost>
     
  11. Boothkicker

    Boothkicker New Member

    Awesome! They are all working except for www.securitycontrol.biz

    When you visit the url, the home page looks like it should and the correct url is displayed, but when you click on a link the url changes to the IP address. What would cause this?


    Nevermind, I figured it out.

    Thanks for everything Falko!
     
    Last edited: Nov 30, 2006

Share This Page