How to Install Apache 2.x and PHP 7 in Windows Step by Step

Installing Apache 2.x and PHP 7 in Windows 10 or Windows 8, 7 is really simple than installing it in the Linux. Here I am going to show you how to install Apache 2.4 and PHP 7 in windows step by step.

Apache and PHP are one of the commonly used web server and programming language, which was used by almost 50% of the websites

Developer March 2016 Percent April 2016 Percent Change
Apache 83,825,658 49.16% 82,446,619 49.15% -0.01
nginx 28,026,677 16.44% 28,196,262 16.81% 0.37
Microsoft 17,228,197 10.10% 16,887,242 10.07% -0.04
Google 13,545,864 7.94% 12,968,162 7.73% -0.21

Since the usage of php and apache was in vast, there are more developers who are all demanding more updates on the PHP and Apache by fixing more security bugs.

Almost 50% of the developers globally know the PHP language and the PHP community was releasing updates regularly to keep it and make it safe. Both PHP and Apache are open source which was available for free from Sourceforge with regular updates.

Now I am going to show you how to install and configure these two open source software in windows operating system.

How to Install Apache in Windows:

Apache is a web server, if you wish to run a web server in your PC or if you wish to run a web server to publish your website, then you need Apache. Installing and configuring Apache in windows is very easy and it involves very few steps to complete the Web server deployment.

Step 1: As the first step you need to download the Apache package from the Apache website. There are two Apache distributions available for download and they are

  1. Apache Lounge
  2. Apache Haus

They both have similar functions but they are built in different codes, so we don’t need to get worried because they do play the same functions. Here I am going to use Apache Lounge.

Read Article :  EASEUS Todo Backup Free Software Download

While downloading the Apache distribution, make sure you have downloaded the binary distribution and download only the respected package i.e. 32-bit or 64-bit which was suitable for your windows operating system.

Step 2: Now download and install Microsoft  Visual C++ for Visual Studio 2015 (VC14) or any respected visual C++ which was required for the Apache package. This can seen in the minimum requirements under the Apache website.

Step 3: Now extract the Apache binary distribution package to C:\Apache24 folder, if you don’t have that folder, then create one under the C Drive. Here 24 is nothing but the version number of the Apache distribution.

Step 4: Now open the command prompt with Administrator rights and run the below commands in the command prompt.

C:\>cd "C:\Apache24\bin"

C:\>httpd.exe -k install -n "Apache 2.4"

This command will direct you to the Apache directory and install the httpd windows services. This installation make sure that every time you reboot or restart your windows operating system, the Apache services will start automatically.

That’s it, now you have successfully installed Apache in your windows operating system. Now you can use ApacheMonitor (located in C:\Apache24\bin\ApacheMonitor.exe) application  to start and stop the Apache services.

How to Install PHP 7 in Windows:

PHP is a open source programming language which was used in millions of website around the globe. If you are a website developer, then you must know PHP, otherwise you cant survey in the web hosting technical industry.

One of the useful advantage over using php is, it was simple to use and easy to understand. PHP community was updating PHP frequently and making it secure for the future use. PHP is a friend of MySQL, you can do a lot with both PHP and MySQL programs starting from applications to websites.

Read Article :  How to Boost the System Speed in Windows 7/8/8.1

Follow the steps below to install PHP 7 in Windows.

Step 1: Download the PHP 7 package (latest is PHP 7.0 (7.0.7RC1)) from PHP Website and make sure you have downloaded the 32-bit or 64-nbit verion whihch was compatible to your windows PC.

There are 2 packages available in PHP 7 they are

  1. Non Thread Safe
  2. Thread Safe

If you are using PHP7 as FastCGI with IIS you should use the Non-Thread Safe (NTS) versions of PHP 7.

You can use either one of the package for windows PC, till you are not using it for production purpose.

Step 2: Now extract the downloaded PHP 7 package to C:\php7 folder. If you not have a folder in that name, then create one. Here the number 7 in the folder name means the php version.

How to configure Apache:

Step 1: Open C:\Apache24\conf\httpd.conf , this is the Apache configuration file, in which you need to make chagnges for Apache server.

Now search for ServerRoot and add the following data.

ServerRoot "C:/Apache24"

Note: You need to add the forward slash “/”

Step 2: Now search for Listen and check whether 8080 is given near listen. This is nothing but the listening port number. If you want to change the port number to 9090 then you need to change the following data from 8080 to 9090 like

Listen 9090

Better you can leave it default in this settings.

Step 3: Now search for DocumentRoot, this is the place from where Apache server documents will be served. Here you need to give the location of the directory.

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

Step 4: Now you need to add the application handler, application type and modules to load. To add those, simply copy the following code to the top or bottom of the httpd.conf file.

Read Article :  How to Install PostgreSQL 10 in Windows 10 and Linux

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php7/php7apache2_4.dll"
PHPIniDir "C:/php7"

Note: You need to add the forward slash “/”

How to configure PHP 7:

Step 1: To configure the PHP, you need to rename the file in  location C:\php7\

C:\php7\php.ini-development

to 

C:\php7\php.ini

After renaming this, your PHP will be ready to work.

Step 2: Now add the “;C:\php7” to the Windows Environment Variable -> System Variable

That’s it, now you can run the php files using your command prompt too.

Testing PHP and Apache Server:

To test Apache and php, you need to start the Apache server by opening the ApacheMonitor (located in C:\Apache24\bin\ApacheMonitor.exe). After starting the service you need to goto to your web browser and open the following link.

http://localhost:8080

Now you can see the Apache index page, this confirms that Apache was working fine.

To test php installation, Goto the following location C:\Apache24\htdocs\ and create a file with the name “info.php”

Open the file with the help of Notepad and paste the following contents.

<?php

phpinfo();

?>

After copying the content to info.php, save the file and goto your web browser and open the following link

http://localhost:8080/info.php

Now you can see the php information page that gives details about your server.

You may also like...

14 Responses

  1. candykeenum says:

    this is so usefull…but i also need how to install nginx…can you help me..

  2. russel says:

    can you please make a post for installing nginx like candy asked…

  3. Akash says:

    Nice post ,Thanks for sharing this post.Helfull

  4. shana says:

    I’d be very thankful if you could elaborate a little bit further on using mariadb.
    Many thanks!

  5. maksimmxpr says:

    will these commands work for the installation of mariadb ?

  6. tania says:

    thanks for the epel commands…

  7. barbmcroberts says:

    please make an article on nginx and lighthttpd.

  8. dolores_chapa says:

    there are lot of ways to install the lamp stack…this is so simple too
    aside from that, wonderful blog!

  9. judi says:

    Apache installation is ver usefull, thankyou for the post..can you please make a post on installing the nosql database
    Thanks..

  10. Bandar poker says:

    It would be better if you have made some clear points on PHP 7..Any way thank you…

  11. Kenin says:

    sure i will try..

  12. bobbie says:

    very usefull article for php installation and configuration.

  13. shauna says:

    thanks a lot.

  14. Jenifer says:

    easy to understand. nice man

Leave a Reply

Your email address will not be published. Required fields are marked *

ten + 18 =