Apache Installation on Windows(Apache 2.4, PHP7)

For Web Developers, one of the requirements for testing web application is having a web server. Apache is one the popular Web Server used for most Web Server. The Apache HTTP server is an open-source Web server application developed by the Apache Software Foundation. The server software is freely distributed, and the open source license means users can edit the underlying code to tweak performance and contribute to the future development of the program.

In this article, I will show you steps on how to install Apache Server on Windows Machine.

How to install Apache 2.4 and PHP 7?

Let’s start:

To get started, download necessary files for this installation.

1. After you download Apache zip files extract the files into your root directory C:/Apache24.

Apache Installation on Windows

2 . Navigate to your Apache directory C:/Apache24/Conf and open file httpd.conf.

Apache Installation on Windows

3. Find and replace the following line below from httpd.conf file.

ServerRoot "c:/Apache24"
ServerName localhost:8080
<Directory />
AllowOverride all
# Require all denied

4. Register Apache Service using a command prompt. Change the CMD directory to C:\Apache24/bin

Apache Installation on Windows

Then, execute command httpd –k install . To install  Apache to your local machine.

Apache Installation on Windows

5. Verify Apache installation using services.msc. Open run command and type services.msc.

Apache Installation on Windows

Services window will open. Search for Apache2.4 service. If it looks like the image below then you have successfully installed Apache and it is already running.

Apache Installation on Windows

6. Create an index.html file inside folder C:\Apache24\htdocs.

Apache Installation on Windows

Run localhost:8080 from your browser to check if it is working.

Apache Installation on Windows

PHP Installation (7.0.13)

To complete Apache Server we also need to install PHP. In my case, I used PHP version 7.0.13. I assume you have already downloaded the files using the link from the beginning of this post.

Apache Installation on Windows
Let’s Start:

1.  Extract the PHP zip files to your root directory which is C://.

Apache Installation on Windows

2. Now open PHP folder and locate files naming Php.ini – development. Rename it to Php.ini

Apache Installation on Windows

3. Open Php.ini files and remove the semicolon to uncomment the lines of code shown below. This will load PHP extensions you need for your development server.

  • extension=msql.dll
  • extension=php_curl.dll
  • extension=php_ftp.dll
  • extension=php_mysqli.dll
  • extension=php_openssl.dll
  • extension=php_pdo_mysql.dll

4. To integrate Php to Apache open httpd.conf from you Apache folder(C:\Apache24\C:\Apache24\conf).Find and replace the lines shown below and make sure that the directory is pointing to your PHP folder(C:/Php).

LoadModule php7_module "c:/Php/php7apache2_4.dll"

PHPIniDir "c:/Php"

5. Restart Apache using httpd –k restart.

Apache Installation on Windows
Check if PHP is working.

Open index.html from C:\Apache24\htdocs and modify code using the line below.

<?php Echo “Hello world” ?>

Open your browser and run localhost:8080 to see if it echoed the word hello world.

Apache Installation on Windows

And we are done. Hope this help!

Happy Coding!!

Leave a Comment

%d bloggers like this: