Installing PHP 7 on Windows 10

  1. Configure PHP as an Apache module
  1. Download PHP for Windows. I prefer to use 7.4.x (current release - 12), so I downloaded the latest VC15 x64 Thread Safe package. I downloaded the .zip file version of the VC15 x64 Thread Safe edition, under the PHP 7.4 heading.
  2. Expand the zip file into the path d:\php7.
  3. Configure PHP to run correctly on your system:
  4. In the d:\php7 folder, rename the file php.ini-development to php.ini.
  5. Edit the php.ini file in a text editor.
  6. Change the following settings in the file and save the file:
    1. Uncomment the line that reads ;extension_dir = "ext" (remove the ; so the line is just extension_dir = "ext").
    2. In the section where there are a bunch of extension= lines, uncomment the following lines:
    1. extension=php_gd2.dll
    2. extension=php_curl.dll
    3. extension=php_mbstring.dll
    4. extension=php_openssl.dll
    5. extension=php_pdo_mysql.dll
    6. extension=php_pdo_sqlite.dll
    7. extension=php_sockets.dll
    8. extension=mysqli
  7. Add d:\php7 to your Windows system path
  8. Open PowerShell or another terminal emulator (I generally prefer cmder), and type in php -v to verify PHP is working.
1
2
3
4
PS C:\Users\myuser> php -v
PHP 7.4.12 (cli) (built: Oct 27 2020 17:18:47) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Configure PHP as an Apache module

Edit httpd.conf,add index.php as a default file name:

1
DirectoryIndex index.php index.html

At the bottom of the file, add the following lines (change the PHP file locations if necessary):

1
2
3
4
5
# PHP7 module
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "d:/php7/php7apache2_4.dll"
PHPiniDir "d:/php7"

Save the configuration file and test it from the command line (Start > Run > cmd):

1
httpd -t