PHP Tutorial Tutorials - Install Apache 2.x on Windows

Install Apache 2.x on Windows

download apache

  1. Open url https://www.apachehaus.com/cgi-bin/download.plx using your browser.

  2. Choose a version to download,here we use Apache 2.4.x OpenSSL 1.0.2 VC14 - Apache 2.4.41 x64
    we will get a file named httpd-2.4.41-o102s-x64-vc14-r2.zip

VC14 means it's compiled by Visual Studio 2015,So download
Microsoft Visual C++ 2015 Redistributable Package (X86 & x64)
at the bottom of page.

Install apache

  1. Extract the file httpd-2.4.41-o102s-x64-vc14-r2.zip to a folder
D:\readme_first.html
D:\Apache24\
D:\Apache24\bin
  1. Install Microsoft Visual C++ 2015 Redistributable Package (X86 & x64) if your windows does not have Visual C++ 2015 installed

Configure file

Edit the file D:\Apache24\conf\httpd.conf

Define SRVROOT "d:\Apache24"
# ServerRoot "${SRVROOT}"
...
...
#Listen 12.34.56.78:80
Listen 80

We will put our scripting files in the DocumentRoot folder.
that is d:\Apache24\htdocs

Line 38: Define SRVROOT "d:\Apache24"
Line 39: # ServerRoot "${SRVROOT}"
Line 248: DocumentRoot "${SRVROOT}/htdocs"
Line 249: <Directory "${SRVROOT}/htdocs">

Start apache web service:

Open a command prompt window, type:

C:\WINDOWS\system32>cd /d D:\Apache24\bin

D:\Apache24\bin>httpd.exe

Test the installation

  1. Open up your Web Browser and typing in the address:
    http://localhost

  2. create a new file d:\Apache24\htdocs\hello.html

<html>
<head><title>hello</title>
<body>Hello Apache!Lautturi.com</body>
</html>
  1. visit the url using your Web Browser:
    http://localhost/hello.html

Install Apache as a service

To run Apache as a Windows Service, in the command prompt type:

D:\Apache24\bin>httpd -k install
Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.

D:\Apache24\bin>httpd -k start

if you use win10,open the command prompt window using keyboard WIN+X,Press Windows+X to open the Power Users menu,then choose Command Prompt(Admin)

Command line Desc
httpd -k install Install Apache as a service
httpd -k start Start Apache service
httpd -k stop Stop Apache
httpd -k restart Restart Apache
httpd -k uninstall Uninstall Apache Service

Check the service

D:\Apache24\bin>services.msc

there would be a service named 'Apache2.4'

Date:2019-08-31 02:33:40 From:www.Lautturi.com author:Lautturi