Categories: PHPWeb

PHP – How to Install Apache 2.4 with PHP 5.6 on Windows



This article represents instructions on what’s needed to be done to install Apache 2.4 with PHP 5.6 on Windows (64-bit). Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.

Following are the key steps/points described later in this article:

  • Install Apache 2.4
  • Install PHP 5.6
  • Configure Apache 2.4 for PHP
  • Configure PHP 5.6
  • Test

Install Apache 2.4

This step looks to be obvious. However, after I am done with the entire installation, it looked to be a bit tricky especially when you got 64-bit Windows. If you go to website, http://httpd.apache.org, you are taken to download page for win32 binaries. If you have 32-bit machine, well and good.

However, if you have 64-bit machine, and you downloaded the install-able from this page, you would end up installing 32-bit apache server which would create issues while configuring 64-bit PHP. What you need is 64-bit Apache 2.4.2 Http server. There are different pages on web from where you could get it. I downloaded it from Apache HTTP Server 2.4.2 x86 and x64 Windows Installers. Take the first one, apache_2.4.2-x64-openssl-1.0.1c.msi (Mirror 1) (Mirror 2).

Install PHP 5.6

For PHP 5.6 version, go to Windows Binaries page and you would see binaries, thread-safe or non-thread safe for both 32-bit and 64-bit WIN platform. As this article is about 64-bit, go ahead and download zip file user “VC11 x64 Thread Safe”.
Once downloaded, unzip it and place it in appropriate folder within C:\ or D:\ directory.

Configure Apache 2.4 for PHP

So far so good. It’s time to configure Apache Http Server. Even before you configure, open a command prompt, go to <Apache Root>/bin and start the server by executing httpd command. If it starts without issue, access http://localhost:8080 and it should display a page saying “It works!”. Add the following command at the end of httpd.conf file which could be found within <Apache Root>/conf folder. Following command assumes that PHP is installed within D:/php

LoadModule php5_module "D:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "D:/php"

In addition to above, go ahead and add index.php to DirectoryIndex variable in following manner:

<IfModule dir_module>
    DirectoryIndex  index.php index.html
</IfModule>

 

Configure PHP 5.6

You are just one step away. Go to <Apache Root> folder and save php.ini-development as php.ini file. Uncomment extension_dir = “ext”. Go ahead and uncomment one or more extensions that you would like to be loaded. For example, extension = php_mysql.dll, extension = php_mysqli.dll etc.

 

Test the Installation

You are all set!!! Go to <Apache Root>/htdocs folder and create an index.php file. Write following code in that file. Open a browser and access http://localhost:8080. You should be able to see Hello World!!! printed with bold letters.

<?php 
echo "Hello World!!!";
?>
Nidhi Rai

Nidhi has been been actively blogging in different technologies such as AI / machine learning and internet technologies. Her field of interest includes AI / ML, Java, mobile technologies, UI programming such as HTML, CSS, Javascript (Angular/ReactJS etc), open-source and other related technologies.

View Comments

Share
Published by
Nidhi Rai
Tags: PHP

Recent Posts

Retrieval Augmented Generation (RAG) & LLM: Examples

Last updated: 25th Jan, 2025 Have you ever wondered how to seamlessly integrate the vast…

7 days ago

How to Setup MEAN App with LangChain.js

Hey there! As I venture into building agentic MEAN apps with LangChain.js, I wanted to…

2 weeks ago

Build AI Chatbots for SAAS Using LLMs, RAG, Multi-Agent Frameworks

Software-as-a-Service (SaaS) providers have long relied on traditional chatbot solutions like AWS Lex and Google…

2 weeks ago

Creating a RAG Application Using LangGraph: Example Code

Retrieval-Augmented Generation (RAG) is an innovative generative AI method that combines retrieval-based search with large…

3 weeks ago

Building a RAG Application with LangChain: Example Code

The combination of Retrieval-Augmented Generation (RAG) and powerful language models enables the development of sophisticated…

3 weeks ago

Building an OpenAI Chatbot with LangChain

Have you ever wondered how to use OpenAI APIs to create custom chatbots? With advancements…

3 weeks ago