by Gina Trapani
Last updated: September 2006
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 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 Software Foundation\Apache2.2\
. When you reach the screen prompting for server information, enter your own email address and homeip.net [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 theC:\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:
Then, comment out the line that starts with <Directory "C:/Program... and add another with your directory, like this:
Last, about 20 lines below that <Directory line, there is a line that reads:
Change it to:
When you're done, save httpd.conf. Then, click on the Apache icon in your taskbar and choose "Restart." If Apache restarts successfully [6], you edited your the file correctly. Visit http://localhost/ in your web browser. This time you should see a listing of your music files. Woo-hoo!
But we don't want just anyone to be able to download your music. Your bandwidth is precious, and we want to secure things a bit. Let's create a password prompt.
First, open a command prompt (go to the Start menu, choose Run, then type cmd.) Change to the Apache bin directory by typing:
Then create a password file by typing:
Replace the path with the path of your new password file (which should in any folder EXCEPT the web server's document root.) Replace gina with the username you want to use. When prompted, enter the password you want to set up. Once you've done that, a password file will be created.
Now we want to apply that login to your music directory. Open up a new file in a plain text editor like Notepad. Copy and paste the following into it:
Make sure you replace
"C:\Documents and Settings\Gina\my_password_file.txt"
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 asC:\Gina\My Music\ .htaccess
.
Note: If you're using Notepad to create your .htaccess file, when you save the file, put quotes around the filename - ".htaccess" - so that Notepad doesn't automatically put a .txt extension on the file. If there's a .txt file extension, your password won't work!
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 is covered in Lifehacker feature How to access a home server behind a firewall.
Enjoy your new home web server!
No comments:
Post a Comment
Jangan Lupa Berilah Komentar!!
Trimakasih atas kunjungannnya.