Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: [SOLVED] running a local site and an external site...

  1. #1
    Join Date
    Aug 2008
    Beans
    21
    Distro
    Ubuntu 8.04 Hardy Heron

    [SOLVED] running a local site and an external site...

    Hi all,
    I am trying to setup my server to run a local network site and an external site.
    I am relatively new to server setup but know my way around Ubuntu.
    I am using the default website virtualhost settings for my external site. I do NOT have a domain name for this external site. Users get to it from another site.
    I can view my external site fine and it all works.

    Where I am lost is how to setup the internal site. I have created a new site-available 'testing' and enabled it and copied the default file and edited it as follows:
    Code:
    NameVirtualHost 192.168.0.189
    <VirtualHost 192.168.0.189>
    	ServerAdmin webmaster@site.com
    	ServerAlias www.testing.site.com
    	DocumentRoot /web/testing/
    	<Directory />
    		Options -Indexes FollowSymLinks
    		AllowOverride None
    	</Directory>
    	<Directory /web/testing/>
    		Options -Indexes FollowSymLinks MultiViews
    		AllowOverride None
    		Order allow,deny
    		allow from all
    	</Directory>
    
    	ErrorLog /var/log/apache2/internal-error.log
    
    	CustomLog /var/log/apache2/internal-access.log combined
    	ServerSignature Off
    </VirtualHost>
    The 'default' site's only difference is:
    Code:
    NameVirtualHost *
    <VirtualHost *>
    	ServerAdmin webmaster@externalsite.com
    	
    	DocumentRoot /var/www/
    	<Directory />
    		Options -Indexes FollowSymLinks
    		AllowOverride None
    	</Directory>
    	<Directory /var/www/>
    		Options -Indexes FollowSymLinks MultiViews
    		AllowOverride None
    		Order allow,deny
    		allow from all
    	</Directory>
    
    	ErrorLog /var/log/apache2/error.log
    
    	CustomLog /var/log/apache2/access.log combined
    	ServerSignature Off
    </VirtualHost>
    Then I edited the /etc/hosts file as follows:
    Code:
    127.0.0.1 localhost.localdomain localhost
    192.168.0.189 testing.site.com www.testing.site.com
    This is not working. Not matter what I type in, I get the files from /var/www/
    Am I going about this wrong? I have never worked with virtual hosts before, so I am completely new to this.

    Ideally I want to have the 'default' site be my external site and the 'testing' site be the internal site.

    Any help is greatly appreciated.
    Thanks!

  2. #2
    Join Date
    Aug 2008
    Beans
    21
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: running a local site and an external site...

    Nobody has any input? I have searched endlessly on this forum with only minimal help.

    I think this should be simple but I can't seem to get it figured out...

    Please someone help!

  3. #3
    Join Date
    May 2008
    Beans
    69

    Re: running a local site and an external site...

    To use NameVirtualHost, you should be using the same IP specifier for all your NameVirtualHost and VirtualHost directives (in this case, probably, "*"). Then, specify the "ServerName" directive so that the server can have something to compare the name the client is using to connect against.

    IIRC, the first VirtualHost that gets loaded for an IP spec this way will be the default host for that IP spec, if none of the ServerName directives match.

    For more, try reading the Apache Virtual Host documentation.

    Derek

  4. #4
    Join Date
    Aug 2008
    Beans
    21
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: running a local site and an external site...

    Ximbiot: I have looked at the Apache docs and no help. Thanks though.

    OK maybe this will make sense... I do not have a domain name for my server. I only use it's IP address.
    Example:
    users click on www.site.com/fun (hosted elsewhere)
    they are redirected to http://xxx.xxx.xxx.xxx/

    That is fine.

    What I then want is if I type in 192.168.0.189 from my machine that is on the same network, I want to get what is in say '/path/here/'...NOT located in /var/www/.


    Maybe this clears things up? IDK I guess I knew less about this than I thought...

  5. #5
    Join Date
    May 2008
    Beans
    69

    Re: running a local site and an external site...

    Quote Originally Posted by a.thomas View Post
    What I then want is if I type in 192.168.0.189 from my machine that is on the same network, I want to get what is in say '/path/here/'...NOT located in /var/www/.
    For "Name-based Vitrual Hosting" to work, you need to access the web server via a host name. Hence the "Name-based" portion of the name.

    Quote Originally Posted by a.thomas View Post
    Then I edited the /etc/hosts file as follows:
    Code:
    127.0.0.1 localhost.localdomain localhost
    192.168.0.189 testing.site.com www.testing.site.com
    If this is the /etc/hosts file on the computer with your browser, you should be able to access the server by name and make things work, but you still probably have to set the config file up as I specified in my earlier post.

    There is also something called "IP-based Virtual Hosting", but you need two IP addresses on your server to pull it off. The Apache documentation link I sent earlier also has a link to information on how to set up IP-based virtual hosts.

  6. #6
    Join Date
    Aug 2008
    Beans
    21
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: running a local site and an external site...

    Quote Originally Posted by Ximbiot View Post
    There is also something called "IP-based Virtual Hosting", but you need two IP addresses on your server to pull it off. The Apache documentation link I sent earlier also has a link to information on how to set up IP-based virtual hosts.
    I know what IP-based Virtual Hosting is... I just can't get it to work...

    I do have 2 IPs... xxx.xxx.xxx.xxx and 192.168.0.189 each with it's own nic card.

    the xxx.xxx.xxx.xxx goes to my dsl modem and the 192.168.0.189 goes to my internal network
    Code:
     sudo ip route
    192.168.0.0/24 dev eth1  proto kernel  scope link  src 192.168.0.189 
    xxx.xxx.63.0/24 dev eth0  proto kernel  scope link  src xxx.xxx.63.12 
    169.254.0.0/16 dev eth0  scope link  metric 1000 
    default via xxx.xxx.63.1 dev eth0  metric 100
    here is my /etc/hosts
    Code:
    127.0.0.1 localhost servername
    here is the 192.168.0.189 config file under /etc/apache2/sites-available/testing
    Code:
    <VirtualHost 192.168.0.189>
            DocumentRoot /web/testing/
    
            <Directory /web/testing/>
                    Options -Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    </VirtualHost>
    here is the xxx.xxx.63.12 config file under /etc/apache2/sites-available/online
    Code:
    <VirtualHost xxx.xxx.63.12>
            DocumentRoot /var/www/
    
            <Directory /var/www/>
                    Options -Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
    </VirtualHost>
    So with this configuration I can get the external site fine from anywhere.
    The internal site (192.168.0.189) returns a 404 not found. Is this due to my file location? i have the files under /web/testing/

    Thanks for any help.

  7. #7
    Join Date
    May 2008
    Beans
    69

    Re: running a local site and an external site...

    Quote Originally Posted by a.thomas View Post
    The internal site (192.168.0.189) returns a 404 not found. Is this due to my file location? i have the files under /web/testing/
    What's in your /var/log/apache/error.log? If the file system permissions are set wrong on /web/testing/ or some such, there should be a message in there...

  8. #8
    Join Date
    Aug 2008
    Beans
    21
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: running a local site and an external site...

    Well I forgot to reload apache after I enabled the testing site...
    so I went back and did it, now I get this

    Code:
    [Tue Aug 19 16:46:24 2008] [error] (EAI 2)Name or service not known: Failed to resolve server name for 192.168.0.189 (check DNS) -- or specify an explicit ServerName

    /var/log/apache2/error.log
    Code:
    [Tue Aug 19 16:37:06 2008] [notice] Graceful restart requested, doing restart
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/gd.so' - /usr/lib/php5/20060613+lfs/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
    [Tue Aug 19 16:37:06 2008] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations
    [Tue Aug 19 16:38:09 2008] [error] [client 127.0.0.1] File does not exist: /htdocs
    [Tue Aug 19 16:38:56 2008] [notice] Graceful restart requested, doing restart
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/gd.so' - /usr/lib/php5/20060613+lfs/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
    [Tue Aug 19 16:38:56 2008] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations
    [Tue Aug 19 16:39:16 2008] [notice] Graceful restart requested, doing restart
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/gd.so' - /usr/lib/php5/20060613+lfs/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
    [Tue Aug 19 16:39:16 2008] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations
    [Tue Aug 19 16:46:24 2008] [notice] Graceful restart requested, doing restart
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    [Tue Aug 19 16:46:29 2008] [error] (EAI 2)Name or service not known: Failed to resolve server name for 192.168.0.189 (check DNS) -- or specify an explicit ServerName
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/gd.so' - /usr/lib/php5/20060613+lfs/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
    [Tue Aug 19 16:46:30 2008] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured -- resuming normal operations
    [Tue Aug 19 16:50:20 2008] [error] [client 192.168.0.110] Directory index forbidden by Options directive: /web/testing/
    It may just be some configuration I set and do not realize...

    Let me know what you think
    Thanks!

  9. #9
    Join Date
    May 2008
    Beans
    69

    Re: running a local site and an external site...

    Quote Originally Posted by a.thomas View Post
    Code:
    [Tue Aug 19 16:50:20 2008] [error] [client 192.168.0.110] Directory index forbidden by Options directive: /web/testing/
    This means you turned off indexes ("Options -Indexes ...", in your config) and you don't have an /web/testing/index.html file. Fixing either one of these issues should solve this.

  10. #10
    Join Date
    Aug 2008
    Beans
    21
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: running a local site and an external site...

    Thank you, I finally saw that. But now I am not sure what this error is?
    Code:
    [Tue Aug 19 16:46:24 2008] [error] (EAI 2)Name or service not known: Failed to resolve server name for 192.168.0.189 (check DNS) -- or specify an explicit ServerName
    Any ideas?

Page 1 of 2 12 LastLast

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
  •