Apache2 web server IP binding

OK, this is sort of a noobish question here.  I have an Apache2 web server running on Ubuntu Karmic with two .php web sites on it.  One site is strictly for internal use and the other I want to be accessed from the Internet.  As most of us know in IIS you can tie a specific IP address to a specific web page.  How can I do this in Apache?  I have tried playing with VirtualHost, but I cannot seem to get that to work correctly.  For you Linux/Apache wizards this should be an easy 500 pts.
Who is Participating?
samriConnect With a Mentor Commented:
hi 219com,

This should be rather straightforward, but then, there are tons of possibilities that could contribute to the "not-working" situation :)

The recommendation given earlier should work -- but I havent got time to validate.

Here are the authoritative docs from Apache on the default apache installation.


On Ubuntu however (I do not have one, so, Google is the way:)


In brief, OS and platform independent, all you need to do is,

1. Makesure the vhost modules is loaded,
2. Enable the Vhosting directive,
3. Create the Vhost container for each vhosts.

Following is a section from httpd.conf from Centos 5.4
### Section 3: Virtual Hosts
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

# Use name-based virtual hosting.
#NameVirtualHost *:80
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common

Open in new window

gelonidaConnect With a Mentor Commented:
The directory to look at is

thre yu create additiona entries
currently you have probably one entry named
and perhaps oen entry named

Let's assume you want to have an hhtp (not https) server
then copy default to (for example) external_server
and copy
default to internal_server

In the beginning of the file change the line named virtual host to something liek
for your internal server

then adapt the rest of the config

in the other file change the Virtualhost entry to the external IP address

if you ant to test from home you could have one server on
and the other on your local network addres

restart apache

and try it out

NameVirtualHost aaa.aaa.aaa.aaa:80
NameVirtualHost bbb.bbb.bbb.bbb:80

<VirtualHost aaa.aaa.aaa.aaa:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain

<VirtualHost bbb.bbb.bbb.bbb:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain

hope it helps
219comAuthor Commented:
Thx guys
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.