Installation of PHP 7 on Windows 10

Step-by-step setup of PHP 7 on Windows 10.

December 07, 2017 | 4

This is a step-by-step setup of PHP 7 on Windows 10.

  1. Download PHP package from PHP website. The latest version as of this time is 7.2.0. Choose VC15 x64 Thread Safe or VC15 x86 Thread Safe for 64-bit or 32-bit OS. In my case, I downloaded the former.
VC15 x86 Thread Safe
  1. Extract the package to C:\php.

  2. Inside php directory, make a copy of php.ini-development and rename it to php.ini.

<img class=“img-fluid” src=“/assets/images/blog/installation-of-php-7-on-windows-10/2.PNG” alt=“PHP Ini”)

  1. Open php.ini and uncomment the following (line 732):
; extension_dir = "ext"
Extension Directory
  1. Add php.exe to Environment Variables's Path. To add, look for Path under System variables and click Edit... button. Click New button and enter C:\php.
Setting Environment Variables Path Setting Environment Variables Path
  1. To test, create a directory: C:\workspace\php. Open your favorite text editor (mine is Visual Studio Code). Add the following codes to a file saved as hello.php inside C:\workspace\php:

echo "Hello, world!";
Test PHP
  1. Open CMD and cd to C:\workspace\php. Run the following command:
php -S localhost:3000 -t .
PHP Built-in Web Server

From PHP site:

As of PHP 5.4.0, the CLI SAPI provides a built-in web server.

This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.

  1. Open your browser and point to http://localhost:3000/hello.php
Open PHP script on browser PHP Built-in Web Server console log
  1. Enable extension you want to use. For example, most likely you will be developing database-driven web applications and you’d want to use MySQL, the world’s most popular open-source DBMS. Install MySQL first if you haven’t done so. Then, open php.ini and uncomment either or both of the following:
Enable MySQL extensions

If you’ve configured a web server Apache HTTP Server for PHP, you will have to restart it’s service for the changes to take effect. As for PHP built-in web server, just run it again.

To test PHP and MySQL connection, you can create a PHP script and call the built-in phpinfo() function to display PHP environment. You should be able to see php_pdo included under PDO.

echo phpinfo();
PHP phpinfo() built-in function

You might also want to create script which creates connection to your database already created in the server.


$dbProvider = 'mysql';
$dbHost = 'localhost';
$dbPort = '3306';
$dbSchema = 'mydb';
$dbCharSet = 'utf-8';
$dbUser = 'julez';
$dbPassword = 'admin';
$dns = $dbProvider . ':host=' . $dbHost . ';port=' . $dbPort . ';dbname=' . $dbSchema . ';char-set='. $dbCharSet;
$connection = new PDO($dns, $dbUser, $dbPassword);

if ($connection) {
    echo 'Database connected!';
} else {
    die('Unable to connect to databese!');

Save it as php_pdo_mysql_test.php and load to your browser.

PHP PDO MySQL connection

It’s done!

Please post your comments or suggestions.