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|
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
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.
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:\>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.
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
- Non Thread Safe
- Thread Safe
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.
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
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.
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.
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php7/php7apache2_4.dll"
How to configure PHP 7:
Step 1: To configure the PHP, you need to rename the file in location C:\php7\
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.
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.
After copying the content to info.php, save the file and goto your web browser and open the following link
Now you can see the php information page that gives details about your server.