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?
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.
2 . Navigate to your Apache directory C:/Apache24/Conf and open file httpd.conf.
3. Find and replace the following line below from httpd.conf file.
# Require all denied
4. Register Apache Service using a command prompt. Change the CMD directory to C:\Apache24/bin
Then, execute command httpd –k install . To install Apache to your local machine.
5. Verify Apache installation using services.msc. Open run command and type services.msc.
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.
6. Create an index.html file inside folder C:\Apache24\htdocs.
Run localhost:8080 from your browser to check if it is working.
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.
1. Extract the PHP zip files to your root directory which is C://.
2. Now open PHP folder and locate files naming Php.ini – development. Rename it to Php.ini
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.
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"
5. Restart Apache using httpd –k restart.
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.
And we are done. Hope this help!