configure http apache web server

Upload: kenneth-christian-bajet-malamion

Post on 09-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Configure Http Apache Web Server

    1/4

    Geek to Live: How to set up a personal

    home web server

    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. Webservers 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 thishow-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 yourmusic collection with friends, or play a song from your home machine at the office forco-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, andthat 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 isrecommended. Still game? Carry on.

    Let's get started.

    What you'll need:

    1. A Windows PC[1]

    2. An always-on broadband (DSL or cable) internet connection

    Step 1. Install Apache HTTP server.[2]

    http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-serverhttp://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-serverhttp://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#1http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#1http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#1http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-serverhttp://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-serverhttp://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#1http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#1
  • 8/8/2019 Configure Http Apache Web Server

    2/4

    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 serverinstallation 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 defaultlocation for the Apache files, inC:\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 the C:\Program Files\Apache Group\Apache2\conf\httpd.conf

    http://httpd.apache.org/download.cgihttp://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#3http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#4http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#5http://httpd.apache.org/download.cgihttp://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#3http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#4http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#5
  • 8/8/2019 Configure Http Apache Web Server

    3/4

    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 addanother 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

  • 8/8/2019 Configure Http Apache Web Server

    4/4

    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:

    AuthType BasicAuthName "This is a private area, please log in"

    AuthUserFile "c:\Documents and Settings\Gina\my_password_file.txt"AuthGroupFile /dev/null

    require valid-user

    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 WEBSERVER 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.

    Note: If you're using Notepad to create your .htaccess file, when you save the file, putquotes 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 surewhat your IP is, visit What Is My IP to find out. If your IP is 12.34.567.890, then typehttp://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 is covered in Lifehacker feature How to access a home server behind a firewall.

    Enjoy your new home web server!

    http://www.whatismyip.com/http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#7http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#7http://www.lifehacker.com/software/feature/special-how-to-access-a-home-server-behind-a-routerfirewall-127276.phphttp://www.whatismyip.com/http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server#7http://www.lifehacker.com/software/feature/special-how-to-access-a-home-server-behind-a-routerfirewall-127276.php