Windows Apache and PHP installation

Time:2020-10-21

Apache download address: https://www.apachehaus.com/cg…
PHP download address: https://windows.php.net/downl…

1. Apache installation

After downloading Apache, unzip it, use CMD to enter bin, and execute the command:

httpd.ext -k install

Install Apache for windows.
After the installation is successful, you can see the following in the computer management service
Windows Apache and PHP installation
When the installation is successful, it will automatically try to start, if it has not been modified httpd.conf There will be the following errors:
Windows Apache and PHP installation
This error enters conf/ httpd.conf Modify the serverroot, as shown in the following figure:
Windows Apache and PHP installation
After modification, it can be started normally. Enter localhost in the address bar, as shown in the following figure:
Windows Apache and PHP installation
Apache installed successfully.

2. PHP installation

PHP download, unzip, enter the main directory, copy php.ini -Development is php.ini 。
modify php.init The extension library path of is shown in the following figure:
Windows Apache and PHP installation
modify php.init The required extensions are shown in the following figure:
Windows Apache and PHP installation
Open Apache’s httpd.conf To configure as follows:

# php7 support  
LoadModule php7_module "D:\ProgramFiles\php-7.2.31/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "D:\ProgramFiles\php-7.2.31"

Create a new one under htdoc of Apache phpinfo.php The contents are as follows:

<?php
    phpinfo();
?>

Restart Apache and enter:

http://localhost/phpinfo.php

As shown in the figure below, PHP is installed successfully.
Windows Apache and PHP installation