WWW FAQs: How do I host more than one website at home?

2007-03-23: Hosting more than one website at home is no harder than hosting a single website at home. Sometimes users think they must have a separate Internet IP address for every website. Then they can't figure out how to purchase that from their Internet Service Provider. And they worry about how to forward the connections from separate IPs through their router. And so on. But all of that is almost always unnecessary.

To host multiple websites at home, just use the Apache web server and name-based virtual hosting. All popular web browsers and servers understand how to handle many separate websites that share an IP address, and they have understood how for years!

Before you read this article, be sure to read my article how do I host my website at home? If you don't understand this article, you definitely need to read that article first.

Setting Up Name-Based Virtual Hosting

To set up name-based virtual hosting, just add the following to your httpd.conf file. If you have configured Apache for Windows in the usual way, you'll find that file in the folder:

C:\Program Files\Apache Group\Apache2\conf

Now, add these lines to the end of the file with any text editor, such as Windows Notepad:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.firstsitename.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/firstsite"

<VirtualHost *:80>
ServerName www.secondsitename.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/secondsite"

And so on, with one VirtualHost container for each site.

Of course, you must actually create the document root folders and fill them with content!

Also, please note that you do not use the \ character in the DocumentRoot path. Use the / character instead. Yes, even though you are hosting on Windows.

This is just the most basic setup possible. You can also customize most other Apache settings inside of a VirtualHost block. For more information, see the Apache Group name-based virtual hosting HOWTO for Apache 2.0.

This article assumes you have installed Apache 2.0 on your computer. If you are using Apache 1.3, see the Apache Group name-based virtual hosting HOWTO for Apache 1.3.
Naturally you need to register all of the domain names and set up DNS for them correctly. That is covered in detail in my article how do I host my website at home?

"But I Want To Use Internet Information Server!"

Microsoft Internet Information Server is capable of name-based virtual hosting, but only if you have Windows 2003 Server. Windows XP Professional will not allow you to host more than one site. I recommend that you simply use Apache to avoid the entire mess. However, if you do have Windows 2003 Server, you can simply open up the Internet Information Server control panel, right-click on "websites," and select "New: Website" to make a new virtual host.

When You Really Do Need More Than One IP Address

There are two major situations that really do call for a separate IP address for every site:

1. Secure sites. Every secure site must have its own IP address. However, hosting secure sites at home is usually impractical anyway. Usually people want secure sites so that they can take credit card orders. And at that point, you should be asking why you want to use something as unreliable as home web hosting for somethign as important as your business. See my article should I host my website at home?

2. FTP sites. FTP does not support name-based virtual hosting. This is an increasingly minor issue as most uses of FTP have been replaced by file upload forms and similar features implemented via HTTP.

If you really do need multiple IP addresses, and you have paid your host for multiple static IP addresses, then you can forward these connections through your router— if you also add separate internal IP addresses to your web server computer, and configure your secure server or FTP server to "listen" on those separate IP addresses.

You can add multiple local IP addresses to a Windows XP or 2003 system by following these steps. I am assuming that you have already given your system one static local IP address and that you have your first home-hosted website working. If you don't, read my article how do I host my website at home? first!

1. Start -> Settings -> Control Panel -> Network Connections

2. Double-click on "Local Area Network Connection" (assuming that you are using wired Ethernet for your server)

3. Scroll down to "Internet Protocl (TCP/IP)" in the list, select it, and click "Properties"

4. You should have a static IP address set already. Click "Advanced."

5. Click the "Add..." button.

6. Enter an additional static local IP address for this computer. Usually you can just add one to the last byte of the static local IP address of your first website. The network mask should be:

7. Keep clicking "OK" until the control panel is closed.

8. Now you can configure Apache (or an FTP server) to bind to these specific addresses. In httpd.conf, you will will write:


Replacing with the static local IP address you have decided to assign to this particular secure site.

Of course, you will also need the rest of the options associated with secure sites, and you must have a version of Apache that included security. For more information, see the Apache mod_ssl documentation.

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!