How to install Apache Server on Windows 7

Before we begin installing Apache Server on Windows 7 the first thing we have to do is downloading the latest version of Apache Server at http://httpd.apache.org/download.cgi.

Update February 2013
As you might notice, Apache.org site does not provide Win32 binaries anymore, So if you want to use the latest Win32 binaries, you can get them from http://www.apachelounge.com

But the sources are available only in zip format, so like it or not, you have to install them manually, but don't worry I have created an article called "Manually Installing Apache on Windows 7"

===

Download the Win32 Binary (MSI Installer) as follows.

apache-install-01

Once you've finished downloading the Apache MSI Installer, double click the file to start the installation.

apache-install-02

Click Next.

apache-install-03

Read the License Agreement - If you have no problem with it check "I accept the terms in the license agreement," then click Next.

apache-install-04

Click Next

apache-install-05

Fill in the following:

Network Domain: localhost
Server Name: localhost
Administrator's email address: admin@localhost

Check for All User on Port 80 as a service. Click Next.

apache-install-06

Select "Custom" for the Setup Type and then click Next

apache-install-07

Click "Change" to change the destination folder. As an example we are going to install the Apache Server into "C:\Apache", later we will install PHP and MySQL in the same folder as well, so it'll be more easier to manage (upgrade) later.

Create a new folder in C drive name it "Apache" or you could just type in "C:\Apache\" in the "Folder name" and then click OK.

apache-install-08

Once we've changed the destination folder, it should be look like the image above. Click Next to continue.

apache-install-09

Now we're ready to install the Apache Server. If there is something you want to change we still have a chance to go back by clicking the Back button otherwise click Install.

apache-install-10

Wait a few moments until Apache Server fully installed. Click "Finish" to exit the installation.

An icon (Apache Monitor) will appear in the System tray icons as shown below. Left click the icon to stop, to start and to restart the Apache Server.

apache-install-11

Don't forget to always restart Apache Server each time we edit or make any changes in the Apache Configuration file (httpd.conf).

Testing Server.

Now it's time to test our server, open up browser in the address bar type in "http://localhost/" or "localhost" and hit Enter.

apache-install-12

Yes! It works, congratulations!

Changing Apache Document root

Next we'll make a few changes to the Apache Configuration file (C:\Apache\conf\httpd.conf) or we can access it from the Start Menu > All Programs > Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File.

Create a new folder in D drive name it "My Websites" or you can create it in C drive if you don't have a D drive.

Open up Apache configuration file "httpd.conf"

Find the line below:

DocumentRoot "C:/Apache/htdocs"

Change the path to D:/My Websites, we've just created.

DocumentRoot "D:/My Websites"

Find the next line:

<Directory "C:/Apache/htdocs">

Change it to the same path with the Document Root:

<Directory "D:/My Websites">

Open up Notepad, copy and paste the code html below:

<html><body><h1>It works too</h1></body></html>

Save the file into D:\My Websites as "index.html" don't forget to change "save as type" with "all files" otherwise the file will become index.html.txt

Restart the Apache Server. Open up browser type in "http://localhost/" and then press Enter.

apache-install-13

Yes! It works too, again congratulations!

Tips:

If "http://localhost" or "localhost" is not working, try "http://127.0.0.1" If the latter works, open hosts file with Notepad. The hosts file is located at "C:\Windows\System32\drivers\etc\hosts" and add the following line to the end of the hosts file.

127.0.0.1 localhost

If you have Skype installed on your system, it likely you will get port 80 problem. To fix this problem, set the application not to use port 80, to do this go to the Tools > Options > Advanced > Connection then uncheck "Use port 80 and 443 as alternatives for incoming connections"

Now we are ready to install PHP VC6 (apache.org binaries.) Do not use PHP VC9 with this Apache Server!

VC9 versions of Apache can be fetched at http://www.apachelounge.com.

Follow the following link to find out of how to update this Apache Server with the Apache Lounge binaries.

22 comments:

  1. very helpful .. many thanks

    ReplyDelete
  2. Thank you...

    The detailed explanation with clear screen shots are really helpful.

    ReplyDelete
  3. hiii i did the installation and it went correctly but then when I type localhost in the web browser I did not get the page that i was expected to get. What I get is: :This page is here because the site administrator has changed the configuration of this web server" .....
    so I need your help. What should I do?

    ReplyDelete
  4. thank you its very helpful.....

    ReplyDelete
  5. yup thanks this is useful..:D

    ReplyDelete
  6. Dear Sir i have an error
    on the time installation.CommandPrompt automatically open with this error:
    data couldnot bind.

    and apache doesn't play.

    If you having any idea kindly reply me on same

    ReplyDelete
    Replies
    1. Do you mean something like "could not bind to address x.x.x.x:80 ..."?, if so, It seems that Apache conflict with another service that using the same port, in this case it's port 80.

      Here is a quick solution, open up Apache configuration file (httpd.conf) and find the following lines:

      Listen 80
      ServerName localhost:80

      Change them both to use port 8888

      Listen 8888
      ServerName localhost:8888

      Delete
  7. thank you its very help full

    ReplyDelete
  8. Thank You soo much ! :) very very neat ,precise and very helpful.God bless buddy !

    ReplyDelete
  9. i am getting the same error as maria khoury sir can u please help Thank u very much

    ReplyDelete
    Replies
    1. If you see something like "Seeing this instead of the website you expected?" It's another Apache test page, not an error. It means that your server has been installed correctly.

      Delete
  10. Thnx Man

    ReplyDelete
  11. AnonymousMay 08, 2013

    Thanks a lot

    ReplyDelete
  12. AnonymousMay 09, 2013

    I am a noob just just trying to learn php by myself i know a little bit of java and c, so i was wondering on what program are u guys opening "httpd" and "php.ini" files? i am opening them on notepad and making required changes

    ReplyDelete
    Replies
    1. Notepad is fine. I personally use Notepad++, it looks much better because it displays line numbers.

      Delete
  13. Hi,
    While installing apache i am getting same error message:
    --------------------------------------------------
    make_sock: could not bind to adrress 0.0.0.:80
    No listening sockets available, shutting down
    unable to open logs.
    --------------------------------------------------
    I tried one of the solution you have mentioned above but still i am not able to start apache.
    Pls help.
    Regards,
    Vishwasdeep

    ReplyDelete
    Replies
    1. The address should be 0.0.0.0:80 not 0.0.0.:80

      But if you have just misstyped, it means that 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, check that PID number in Task Manager to find what program using that port.

      Delete
    2. Yes, you were right. 0.0.0.0:80 is already in use.
      I checked using cmd and 0.0.0.0:80 is assigned to "System" with process id '4'.
      I tried a lot to kill the task but it says, "Access Denied" and without killing this task i cant run apache.
      Any solution for this...????

      Delete
    3. Sorry for the delay...
      I am not good at system troubleshooting, perhaps this link can give you some clues to solve your problem why-is-system-process-listening-on-port-80

      Delete