PHP Configuration
Download the latest PHP version from the official Windows repository. Extract the archive to a dedicated directory such as D:\WebDev\php-8.2.0.
Navigate to the extracted folder and create a working configuration file by copying php.ini-development and renaming it to php.ini.
Open the configuration file and locate the extension_dir directive. Update it to point to the extensions folder:
extension_dir = "D:/WebDev/php-8.2.0/ext"
Enable the required extensions by removing the leading semicolon from these lines:
extension=gd2
extension=mysqli
extension=mbstring
Set the timezone configuration:
date.timezone = Asia/Shanghai
Apache Configuration
Obtain Apache for Windows from the official download page. Extract to D:\WebDev\Apache24.
Edit conf\httpd.conf and replace all instances of c:/apache24 with your actual installation path D:/WebDev/Apache24.
Insert the PHP module loading directives before the <IfModule unixd_module> section:
LoadModule php_module "D:/WebDev/php-8.2.0/php8apache2_4.dll"
PHPIniDir "D:/WebDev/php-8.2.0"
AddType application/x-httpd-php .php .html .htm
Uncomment and configure the server name:
ServerName 127.0.0.1:80
To modify the listening port, update the Listen directive:
Listen 8080
Add default index files for directory browsing:
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
Open Command Prompt with administrator privileges and regisetr the Apache service:
cd D:\WebDev\Apache24\bin
httpd.exe -k install
Launch ApacheMonitor.exe from the bin directory and click Start to begin the service.
Testing the Installation
Create a test file at D:\WebDev\Apache24\htdocs\test.php:
<?php
echo "Environment verification: " . phpversion();
phpinfo();
?>
Access http://127.0.0.1/test.php in your browser. The phpinfo output confirms Apache is correctly parsing PHP files.
MySQL Installation
Download the MySQL installer from the official website and run through the setup wizard. During installation, select the appropriate distribution type and configure the root password. Once complete, verify the installation by connecting via command line or a database management tool.