Manually Installing Apache Server on Windows 7

If you have any previous version of Apache (MSI Installer from apache.org) installed on your system, please uninstall it first from Add/Remove program.

Download Apache Web Server from:

http://www.apachelounge.com/download/ - Windows 32bit
http://www.apachelounge.com/download/win64/ - Windows 64bit

For your reference, My Operating System is Windows 7 Professional 32bit, I use "httpd-2.4.3-win32-ssl_0.9.8.zip" for this installation.

To be able to run Apache 2.2 and 2.4 VC10, Visual Studio C++ 2010 SP1 must be installed on our system. Follow the link below to download it, after you've finished downloading the file double click the file to install it.

Ms Visual C++ 2010 SP1 Redistributable Package (x86) - Windows 32bit
Ms Visual C++ 2010 SP1 Redistributable Package (x64) - Windows 64bit

Updade: Novemeber 2013

If you want to use Apache 2.4 VC11 (Minimum system required: Windows 7 SP1), Visual Studio C++ 2012 must be installed on our system. Follow the link below to download it.

Ms Visual C++ 2012 x86, x64 Redistributable Package Windows 32bit and 64bit.

=== end of update.

If you want to use Apache 2.2 and 2.4 VC9 you can follow the link from here. Apache Server VC9 version

Configuring Apache server


Create a new folder in C Drive name it "Apache" extract the httpd zip file you've downloaded to anywhere on your computer and then copy all files and folders over into "C:\Apache" - Navigate to "C:\Apache\conf" folder, double click "httpd.conf" to open it.

Find the Server Root:

ServerRoot "c:/Apache24"

Change it to:

ServerRoot "c:/Apache"

Next line: Server Admin

ServerAdmin admin@example.com"

Change it to:

ServerAdmin admin@localhost

Next line: Server Name

#ServerName www.example.com:80

Uncomment the line and replace www.example.com with localhost:

ServerName localhost:80

Next line: DocumentRoot and Directory

DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">

Change the lines to:

DocumentRoot "c:/Apache/htdocs"
<Directory "c:/Apache/htdocs">

Next line: cgi-bin Directory

<Directory "c:/Apache24/cgi-bin">

Change it to:

<Directory "c:/Apache/cgi-bin">

Save the configuration file.

Installing Apache


Now, go to the Start Menu > All Programs > Accessories, right-click "Command Prompt" and then click "Run as Administrator"

Navigate to the Apache's bin folder by typing "cd \apache\bin" in the Command shell and then press Enter, type in "httpd -k install" to install the Apache service and then press Enter. If you got any error displayed here, you should fix them first before you try to start the Apache Server. To start the Apache Server simply type in "httpd -k start" and then press Enter.

For more detail see the image below:

Apache Command Prompt

Open your browser and navigate to "http://localhost"

Apache Test Server

Good job!,

Now you can change your Apache Document Root and Directory to make it easier to follow my other tutorials.

Uninstall Apache


In case, if you want to upgrade/downgrade or remove Apache completely from your system follow the steps below.

Open Command Prompt with administrator right (Start Menu > All Programs > Accessories, right-click "Command Prompt" and then click "Run as Administrator") type in "cd \apache\bin" and press Enter, first we will stop the Apache server, type in "httpd -k stop" and then press Enter. Next type in "httpd -k uninstall" to uninstall the Apache Service.

For more detail see the image below:

Apache Command Prompt

That's all, you are safe to delete "C:\Apache" folder or replace it with other versions of Apache.

The next step is installing PHP, use PHP VC9, VC11 thread safe with this Apache server, make sure to use the right binaries, do not mix x86 with x64 binaries.

20 comments:

  1. Nice post.. helped me a lot. Thanks..

    ReplyDelete
  2. Dave ThompsonMarch 29, 2013

    You make it so simple. Excellent, clear instructions. Thanks

    ReplyDelete
  3. thANKS A lot....

    ReplyDelete
  4. Hey, thank you very much, I was so stuck with this insignificant thing... Thanks....

    ReplyDelete
  5. Work like a charm

    ReplyDelete
  6. thanks. Why it is necessary to rename folder Apache24 to Apache?

    ReplyDelete
    Replies
    1. It's not necessary, we rename that just to follow the previous installation.

      Delete
    2. AnonymousMay 12, 2013

      I couldn't open httpd.conf file. which program should I use to open it?

      Delete
    3. You can open that file with Notepad.

      Delete
  7. AnonymousMay 17, 2013

    This worked perfectly as the MSI for Apache 2.2.2 failed to start and had loads of errors

    ReplyDelete
  8. 2.4, Windows 7, installed in a D: drive folder, and everything worked perfectly, first time. Thank you for these excellent instructions.

    ReplyDelete
  9. Hi
    I have installed vcredist_x64 visual studio and httpd-2.4.12-win32-VC11 apache from your given links. I followed all instruction given by you; however while running httpd -k install command thr cmd I m getting an "The Program can't start because MSVCR110.dll is missing from your computer. Try reinstalling the program to fix this problem".
    please help me to fix it.

    ReplyDelete
    Replies
    1. The reason is 32-bit process cannot load 64-bit DLLs. You've installed httpd-2.4.12-win32-VC11, try to install vcredist_x32 (x86) visual studio as well.

      Delete
  10. thank you so much its really very helpful :)

    ReplyDelete
  11. thanku.. :)
    but i got some errors while installing apache and starting it...
    "no listening sockets available..AND unable to open logs"
    what i hav to do?how it can be resolved..pls help me.. :(

    ReplyDelete
    Replies
    1. It seems the port 80 is already used by another program, it can be firewall, antivirus or any other programs.

      You can run "netstat -ano" from command prompt, click Start/Run and then type netstat -ano, you will see something like TCP 0.0.0.0:80 and in the last column there is a PID column, check that PID number in Task Manager to find out what program using that port.

      Delete
  12. hey its only works in IE but not in firefox and chrome browser

    ReplyDelete
    Replies
    1. I can access it in any browsers here, sorry I can't help you. Maybe it's something to do with your browser's settings, try to clear browser's cache, disable add-ons, proxy and see if it will solve your problem

      Delete