These are Brian Schoenbaechler's ramblings, rants, and raves about his life trying to grow his Small Business.

Sunday, September 11, 2005

How to set up a personal home web server

How to set up a personal home web server

A web server is software that continuously runs on a computer and allows other computers to download documents from it. This text that you’re reading right travelled over a network connection from Lifehacker’s hosting web server to your browser. Web servers are usually loud, scary, headless machines in cold windowless rooms, but you can run one under your desk at home.

Why would you want to run a home web server? Maybe you want to download files on your home computer from anywhere. Like, say, your digital music collection. In this how-to, we’ll set up a home web server that lets anyone (with the right password!) connect to your computer and download your MP3’s from it, for a nice way to share your music collection with friends, or play a song from your home machine at the office for co-workers.

Please note: Running a server on your home computer is a risky undertaking, and before you start, make sure your computer has all the latest patches and security updates, and that you’ve done a thorough spyware and virus scan. This tutorial is for advanced users who feel comfortable editing textual configuration files and exposing port 80 on their home computer to the internet. As always, a strong firewall with explicit user-set rules is recommended. Still game? Carry on.

Let’s get started.

What you’ll need:

A Windows PC [1]
An always-on broadband (DSL or cable) internet connection

Step 1. Install Apache HTTP server. [2]

First and foremost, disable and stop any other firewall or server software you may have running, including Windows Firewall, Skype, Trillian or any other instant messaging applications. This is extremely important, and if it’s not done, can cause the server installation and startup to fail miserably. These programs and services can be started and used again as usual once we’re done setting up the web server.

Download Apache HTTP Server from here, using the link under “best available version” next to “Win32 Binary (MSI Installer).” Start the installation wizard. Accept the license agreement and use the default location for the Apache files, in C:\Program Files\Apache Group\Apache2. When you reach the screen prompting for server information, enter your own email address and [3] as the domain information, like so:

Complete the installation wizard using the “Typical installation” setting.

When it’s done, open your web browser and go to http://localhost/. If the page you see reads, “If you can see this, it means that the installation of the Apache web server software on this system was successful,” you’re golden. [4]

Step 2. Configure Apache to share documents from the right folder.

Say you want to make your music collection downloadable using your new web server [5], and all your music files are located in C:\Gina\My Music. Using a plain text editor like Notepad, open the C:\Program Files\Apache Group\Apache2\conf\httpd.conf file. This is Apache’s configuration file, which looks long and scary, but most of the defaults will work just fine for us. We just have to change a few things.

In this httpd.conf file, comment out the line that starts with DocumentRoot and add another with your directory, like this:

#DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
DocumentRoot "C:/Gina/My Music"

Then, comment out the line that starts with

Last, about 20 lines below that
require valid-user

Make sure you replace C:\Gina\my_password_file in the text with your own password file created above. Save this new file IN YOUR WEB SERVER DOCUMENT ROOT (in this case, C:\Gina\My Music) and name it .htaccess. Don’t forget the dot in the beginning, before .htaccess. So, in this case, we’re saving the file as C:\Gina\My Music\ .htaccess.

Now, using your web browser, go to http://localhost/. You should be prompted to log in. Enter your username and password you set up in your password file. Rock!

Step 4. Congratulate yourself. You’ve got a home webserver running.

If you are NOT behind a firewall, you can access your web server from other computers by typing your computer’s IP address into a web browser’s address bar. If you’re not sure what your IP is, visit What Is My IP to find out. If your IP is 12.34.567.890, then type http://12.34.567.890 into a browser’s address bar. [7]

If you ARE behind a firewall (like a wireless router), you’ll need to open up port 80 on the firewall and forward it to your computer. This part is beyond the scope of this article, but will be covered in a future Lifehacker feature.

Enjoy your new home web server!

— Gina Trapani


[1] Sorry Mac folks, but OS X comes with a web server all set up, so this tutorial’s not for you. [back up]

[2] There are other web servers out there, but we’re going with Apache HTTP server because it’s free, stable, and my favorite. [back up]

[3] It doesn’t matter what domain you put here. I chose because it’s descriptive, and one of DynDNS’s home domains. [back up]

[4] A common during-installation error with Apache reads, “Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address no listening sockets available, shutting down. Unable to open logs.” This means that some other server program (like Skype) is interfering with Apache. To figure out what program it is, open a command prompt and type:

netstat -a -oFind the PID (Process ID) of the program running on your local machine on port 80 (or http.) Then open the Windows Task Manager (Cntl-Alt-Del). In the View menu, choose Select Columns, and check off PID. Then match the PID to the running process to find out what server program is running, and stop the program. Then retry the Apache installation. [back up]

[5] There are tons of uses for your personal web server beyond a password-protected jukebox. Publish your blog at home, host a personal wiki, share video files and photos. Basically any file you want to publish as read-only is a good candidate. A home web server has the advantage over special server/client software because it only requires a web browser to connect to it. [back up]

[6] If Apache doesn’t start correctly, it’s because it can’t read the httpd.conf file, which means you probably had a typo in your changes. Check your changes very carefully, save and restart Apache to try again. [back up]

[7] Keep in mind that depending on your internet service provider, your computer’s IP address may change. There’s an easy way to set up a memorable name that doesn’t change, but that topic will be covered in an upcoming Lifehacker feature. [back up]