Himz
Himz

Reputation: 523

Running many websites on one server

This may be a duplicate question, but i have been thinking about it for long. I know, apache supports hosting many websites on a single server. But i want to know the implementation.

The server will have the single IP address. TCP is always port 80. Then how is it possible to run 10 different websites on a single machine. Also DNS, has one-to-one mapping.

I am thinking, probably some tweaking is done in HTTP protocol, but cant think of exact and best possible solution .

Thanks

Upvotes: 0

Views: 174

Answers (1)

ChrisC
ChrisC

Reputation: 2469

You can add many VirtualHost entries in your Apache config as follows:

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

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

This basically prompts Apache to respond differently, serving different documents based on which domain was requested.

More information can be found in the Apache docs: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Upvotes: 1

Related Questions