Configuring Apache with PHP 8.2.3 on Windows 10
Download and Install Apache:
If you don’t have Apache installed, download the latest version of Apache HTTP Server for Windows from Apache Lounge.
Extract Apache to a directory, for example, C:\Apache24.
Configure Apache to Use PHP:
Open the Apache configuration file httpd.conf. This file is usually located in the conf folder inside your Apache directory (e.g., C:\Apache24\conf\httpd.conf).
Open it in a text editor with administrator rights (e.g., Notepad++ or run Notepad as admin).
Load PHP Module and Set Handler:
Add the following lines at the end of the httpd.conf file to load the PHP module and configure Apache to handle PHP files:
# Load PHP module
LoadModule php_module "C:/php/php8apache2_4.dll"
# Configure PHP file handling
AddHandler application/x-httpd-php .php
# Set the PHP ini directory (if needed)
PHPIniDir "C:/php"
Make sure the path matches your PHP installation folder and that the file php8apache2_4.dll exists in your PHP folder. If it’s missing, you may need to download the PHP version with the Apache module included.
Set DirectoryIndex to Include index.php:
Find the DirectoryIndex directive in httpd.conf and add index.php so Apache can serve PHP files by default:
DirectoryIndex index.php index.html
Restart Apache:
Save the configuration file.
Restart Apache from the Apache Monitor or by running the following commands in an elevated Command Prompt:
net stop apache2.4
net start apache2.4
Test PHP with Apache:
Create a file named info.php in Apache’s htdocs folder (usually C:\Apache24\htdocs).
Add the following content:
<?php
phpinfo();
?>
Open a web browser and navigate to http://localhost/info.php.
You should see the PHP information page confirming PHP is working with Apache.
TAGS:
#PHP
#Install
#Windows10
#php8.2.3
#HowToInstallPHP
#Windows10/11
#XamppInstallation
#Apache
#MySQL
