Beginners Guide: Install Apache 2 Web Server on Windows (Local Installation)

September 2, 2007 – 11:12 pm

For beginners out there, here is a simple guide for you to run Apache 2 web server locally on your Windows machine. Running a web server locally means that you will give your machine a local, imaginary domain name such as www.yourmachine.com or www.ihavemyownwebserver.com.

 

apache-logo

A local web server can serve web pages as a live web server, but it is restricted to machines from your local area network. A local web server can’t server web pages to users on the Internet – you need to buy a proper domain name and a live web hosting service for that to work.

 

Advantages of a Local Web Server

  • It is free to use – you don’t have to buy anything to have a local web server. You don’t need to have a live Internet connection to run it too!
  • Great for testing out products – you can test many web applications with a local web server. You can run WordPress, ActiveCollab and more!
  • Enjoy the same web server experience – running a local web server does not differ much from running a live one. The only difference is that your web server will only be available on your LAN.

 

 

Step by Step Installation of Apache 2 Web Server on Windows

I tested this on my machine that runs Microsoft Windows 2000 Professional. Windows XP users should have no problem using this guide.

 

Network Setup

1- Open up your “hosts” file with a Notepad. On Win2K, it is located at C:\WINNT\System32\drivers\etc. On WinXP it is located at C:\Windows\System32\drivers\etc.

 

2- Check out the line that starts with 127.0.0.1. Add your imaginary web server name at the end of the line. Put something like www.syahid.com or www.mywebserver.com. Save your “hosts” file.

A “hosts” file is used to map your IP address to a server name. In this case, 127.0.0.1 equals the web server name of your choice.

Example hosts file line: 127.0.0.1 localhost syahid www.syahid.com

 

3- Click your Windows Start button. Click on “Run“. Type “cmd” and click Enter. A DOS command prompt will appear.

 

4- Type “ping www.syahid.com” or whatever name you give your web server before. Your machine should give a reply as shown in the picture below.

ping-your-own-web-server

 

Download and Install Apache Web Server

5- Go to Apache 2 download page. Always download the latest stable version. During the time of this installation, the recent stable version of Apache 2 for Windows installer (.msi file) is 2.2.4. Download this file to your Desktop.

 

6- Right click on the the installer file, select “Install“. Accept the agreement and click Next. Click Next once more.

 

7- Fill in your web server information details as shown in the screenshot below.

apache-server-information

For example, if your server name is www.syahid.com, here is what you fill in in the fields:

  • Network name : syahid.com
  • Server name : www.syahid.com
  • Administrator’s name: <leave this as default>

Click Next again.

 

8- Select “Typical Install“. Click Next.

 

9- Accept the default installation path – C:\Program Files\Apache Software Foundation\Apache2.2\ , or change it according to your preferences. Click Next to proceed.

 

10- Wait until the installation is over, then click Next once more and click Finish to wrap up the installation process. Apache will starts automatically and you can see a “green Apache icon” on your taskbar.

apache-server-started-icon-on-taskbar

 

Test Apache Web Server Installation

11- Click on the icon as shown above, click “Open Apache Monitor“. Try to Stop, Start and Restart the web server service from the Apache Monitor console. Make sure every step is successful.

test-apache-start-shutdown-restart-apache

 

12- Open up your browser. Type in your web server address, e.g http://www.syahid.com . If there is no problem with your installation, you shall get the “It works!” page.

apache-installed-and-working-it-works-screen

 

Your Apache 2 web server installation is a success! Congratulations! Now you can fill in your web server directory with all your HTML files. Your default web directory page will be C:\Program Files\Apache Software Foundation\Apache2.2\htdocs .

 

That was easy! Maybe next time I will show you on how to integrate support for PHP and MySQL into this installation. So don’t forget to check out this site soon!

 

Tags: , ,

Share!

Related Posts:


  1. 58 Responses to “Beginners Guide: Install Apache 2 Web Server on Windows (Local Installation)”

  2. one Apache package that I have used for some time is Apache2 Triad, a WAMP distribution. this has a full install of Apache,PHP,Perl,Mysql,SlimFTP and more. Which makes testing database driven apps,and php apps and more very simple with a one click install

    By CrossFire on Sep 4, 2007

  3. yes this is also possible. you can even use an application called xampp. but if you want to learn a little bit extra, manual installation is the best!

    By syahid on Sep 4, 2007

  4. sy dah berjaye install but then i cant run the apache weh server…y is that?..thanks

    By najlaa on Sep 17, 2007

  5. can you please check C:\Program Files\Apache Software Foundation\Apache2.2\logs\error.logs. And what do you mean that you can’t run apache server?

    By admin on Sep 17, 2007

  6. thank you!

    By aserty on Oct 23, 2007

  7. you are welcome!

    By TechMalaya on Oct 23, 2007

  8. Hi, thanks a lot!

    By Aki on Nov 2, 2007

  9. you are welcome. do share this among your friends for mutual benefit. :D

    By TechMalaya on Nov 2, 2007

  10. Tak perlu susah-susah. Muat turun saja dan pasang Apache2Triad. Semuanya akan ditetapkan oleh perisian berkenaan dengan sendiri. Saya telah lama melaksanakannya.

    By dr izdor on Dec 8, 2007

  11. @ dr izdor: Betul. Tapi kalau inginkan lebih fleksibiliti, menambah kemahiran diri. Setup sendiri adalah cara terbaik. Dan saya pasti Apache2Triad tak sesuai untuk production web server.

    By Syahid Ali on Dec 8, 2007

  12. when installing apache 2.2 on winxp get a error message cannot open device or specific folder

    By kevin on Mar 12, 2008

  13. posted message sorted error it was due to the file being encrypted – thanks for your site

    By kevin on Mar 12, 2008

  14. Hi Syahid,

    Thanks for your instructions, I successfully installed Apache, but got the following errors. Please help!

    1. What is “The operation has failed?” after I clicked Start from Apache Service Monitor?

    2. What does this mean on Error Log?
    [Fri Apr 11 20:40:59 2008] [crit] (OS 10022)An invalid argument was supplied. : Child 2344: setup_inherited_listeners(), WSASocket failed to open the inherited socket.
    [Fri Apr 11 20:40:59 2008] [crit] Parent: child process exited with status 3 — Aborting.

    Thanks – Jon

    By Jon on Apr 12, 2008

  15. @Jon: I recommend that you uninstall, delete the Apache folder, and reinstall Apache again. That looked serious! If it happened again, go to Apache Forum for expert tips.

    By Syahid A. on Apr 12, 2008

  16. Everything went perfectly for Apache 2.2.8 install onto my Tablet Laptop running XP Pro. Thanks for the help/screenshots. Now I plan to install MySQL 5.0.51a & PHP 5.2.5

    All so I can learn and help with the growth and development of an older website

    Thanks again and if you know of any great tutorials…

    By Joe on Apr 24, 2008

  17. @Joe: Good luck Joe! I hope you can continue all the planned work with success.

    By Syahid A. on Apr 24, 2008

  18. Superb! Thanks a ton.

    By Rajesh Panchal on May 14, 2008

  19. I have followed the instructions above, and installed apache2.2.6 on D:\Apache2.2. My httpd config:
    ServerName testing.co.nz:8080
    Listen 8080

    The server is running and stopping fine, except when i typed http://www.testing.co.nz in the firefox browswer i was propmted for the username and password.

    How ever if typed http://www.testing.com:8080 i get “It works” page.

    where do i go wrong please help me…..can someone explain to me. thanks.

    By 11Tigers on May 29, 2008

  20. @11Tigers: I don’t know what went wrong. Looks like a broken .htaccess file / misconfiguration. Try Listen 80, and ServerName http://www.testing.co.nz first before changing it to 8080. Make sure that you are not running any other service with port 80 or 8080. And one more, make sure you can ping http://www.testing.co.nz and that it points to your computer, not other external servers please.

    By Syahid A. on May 29, 2008

  21. Hi again, can you tell me is the set up for the above the same on windows vista? (just bought a new laptop and its got this rubbish on it!)

    By kim on Jun 22, 2008

  22. @kim: You should try it then. Never tried it on Vista. Not a fan of the OS either. lol.

    By Syahid A. on Jun 23, 2008

  23. if i don’t have a domain name, i can use “localhost” in network name and server name right? would i need to put “localhost” in the hosts file and use the 127.0.0.1 ip address?

    By Darren on Jun 23, 2008

  24. @Darren: I use the one without OpenSSL. Just put up an imaginary domain name at the end of the 127.0.0.1 line. Make sure you can ping it and get a reply.

    By Syahid A. on Jun 23, 2008

  25. Hi again, just to say yes it does work on vista without too much pain either! You cant add your imaginary web name to the host file and so have to use localhost, but everything else works the same! Still cant stand vista but needs must it works! Thanks

    By kim on Jul 1, 2008

  26. just a quick update. Yes you can add your imaginary web name to the host file….. you just need to run notepad in administrator mode! I now have php5, mysql, apache, pear and phpmyadmin all working on vista. Thanks to this tutorial! working on my first content management system!!! eck

    By kim on Aug 13, 2008

  27. @kim: Congrats Kim!

    By Syahid A. on Aug 13, 2008

  28. Syahid

    I have followed your instructions to install Apache but I keep this error message, I have uninstalled and deleted the folder four times now but I still the same error message

    Httpd.exe: Could not reliably determine the server’s fully qualified domain name, using 10.235.221.232 for ServerName
    Only one usage of each socket address
    is normally permitted. : make_sock: could not bind to address 0.0.0.0.80
    no listening sockets available , shutting down
    Unable to open logs
    Note the errors or messages above, and press the key to exit.

    Please advise what I can do to resolve this problem

    By Wisdom on Aug 29, 2008

  29. @Wisdom: Shut down your Apache server. In command prompt, type netstat. If you can find some other addresses that is currently using port 80, you need to find that process first before you can run Apache again. Based on your log, I think there are other services that are currently using port 80 (http port). And do make sure you have the rights to install applications as the machine / Windows administrator.

    By Syahid A. on Aug 29, 2008

  30. Thanks I have sorted it out Apache is running fine what I want to do next is to install Mod_Security in Apache been trying but having some difficulties any ideas to help me

    By Wisdom on Aug 29, 2008

  31. Syahid,

    I just tried your tip and almost done. But some errors are still coming . I tried removing the directory and installing again. Can you help me out.

    ————————————
    Installing the Apache 2.2 Service
    The Apache 2.2 service successfully installed.
    Testing httpd.conf
    Errors reported here must be corrected before servicecan be started.
    httpd.exe: could not relaibly determine the servers fully qualified domain name, using 123.237.135.53 for server name
    (OS 10048) Only one usage of each socket address(protocol/network address/port) is normally permitted. make_sock : could not bind to address 0.0.0.0:80 no listening sockets available

    By K.Kumar on Sep 13, 2008

  32. @K.Kumar: It seems that port 80 had already been used by another web server. Remove the previous application and di restart Apache. Make sure your firewall did not block access to port 80 via to the IP address above + localhost.

    By Syahid A. on Sep 14, 2008

  33. Thanks. Done

    By KK on Sep 14, 2008

  34. hi, thank you very much for taking time to post these instructions, tried it and it works.

    By kerigan on Oct 4, 2008

  35. Hi,

    thanks for posting these instructions!!

    was lost, now have apache running

    many thanks

    Mike

    By mike robinson on Oct 15, 2008

  36. So getting the webserver to works is …easy but now i need to connect it to dreamweaver and the php files- that seems to be the hardest ..right maybe a link or a tutorial please.. i am using windows vista thank you

    By bod on Oct 28, 2008

  37. @bod: I don’t think it is that hard. Sorry, but I don’t have an idea of how that works. Maybe you can check out the Dreamweaver tutorial.

    By Syahid A. on Oct 28, 2008

  38. how to make another pc ( client) can connect to my web server? F.Y.I i only allow my web server to be seen in LAN….

    i hope someone can HELP me..

    tq…..

    By zafrol on Nov 2, 2008

  39. @zafrol: Check out my HFS server tutorial with DynDNS setup.

    By Syahid A. on Nov 4, 2008

  40. in case of having IIS installed the error “other webserver using same port” will show up, go to controlpanel/administrative tools/services and stop and disable iis and windows process controller.
    Reinstall apache server, and all will be ok!!!

    By Santos on Nov 10, 2008

  41. Thanks a lot. Your help was super!!!!!!

    By Argy13 greece on Feb 14, 2009

  42. First off, thanks for your tutorial! I have a problem not discussed here as far as I can tell. Apache is running great, but the when I put the second site’s URL in a browser, I get the first site’s contents. Any ideas on how to clear this up? These sites are not just local, they should be accessible via internet. Thanks.

    By wencooley on Feb 18, 2009

  43. @wencooley: Do you setup two Apache servers inside your local LAN and you want to have them accessible via the Internet? I think you need to play around with static IP + DNS.

    By Syahid A. on Feb 18, 2009

  44. Thank you for the useful guide. Finally a computer whiz that can break it down for us noobies.

    By Shane on Feb 27, 2009

  45. thank you for this very useful guide

    By mirsad on Mar 12, 2009

  46. Hi, my apache server is working fine. But after that I installed mysql in my pc and configured accordingly. All other normal php pages are displayed properly but when I connect to mysql database thru php error logged in log file as follows

    ‘http://localhost:8080/test.php’
    error logged at error.log as “httpd.exe: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

    By maggie on Mar 14, 2009

  47. @maggie: I’ve never used 8080 in the above guide. Check your host name and port number. Make sure what you enter in the MySQL config is the FQDN in all your setup previously. Then, I doubt the error will happen again.

    By Syahid A. on Mar 14, 2009

  48. At last I’ve been able to make Apache work
    Thank you so much

    By Sioux on Apr 22, 2009

  49. I was wondering if you could set up some sort of system so when your publish a new article, i get emailed to alert me? Or something like that.

    By los angeles home investor on Apr 25, 2009

  50. Im stuck, i had the 0.0.0.0:80 error and fixed it by changing the port to 81, and now i have the server running, however when i try to access it i get a “403 Forbidden” – “You don’t have permission to access / on this server.”

    By CarbonEagle on Jul 16, 2009

  51. This is very nice article. I never used hosts files to access my server. Normally I just route my ips to domains name. I will give it a try.

    regards

    Kamal.

    By Kamal Panhwar on Oct 7, 2009

  52. I am trying to save the hosts file. I typed in my server name, and I get an error code saying that it cannot save my hosts file.

    … Is there a way to bypass that message?

    By Jaime on Mar 8, 2012

  53. you must edit the file in administrator mode. right click on notepad, choose run as administrator. afterwards, select the hosts file and edit it.

    By Syahid A. on Mar 13, 2012

  54. Thank you for the great guide.

    By Div on May 26, 2013

  1. 5 Trackback(s)

  2. Sep 10, 2007: Beginners Guide: Install PHP 5, MySQL 5 on Apache 2.2 on Windows (with screenshots!) | TechMalaya.com
  3. Sep 12, 2007: Freeware: Manage Your MySQL Database with Web-Based PhpMyAdmin | TechMalaya.com
  4. Jun 9, 2008: How to Setup More Than One Website in a Single, Local Apache 2.2 Installation (with screenshots!)
  5. Oct 18, 2008: install Apache | 『我們都要向前衝』
  6. Dec 18, 2011: Apache 2.2 on Windows – How I configured it « Wildkatz Development

Post a Comment