If you are a PHP/MySQL developer, it is very important to be able to work on your application locally in your own environment, since you can make changes and update to your application quickly and effectively. The instruction below will help you to setup your environment with the latest version of Apache, PHP, and MySQL. For any reasons, you are still using the older versions, you can follow the old setup of Apache, PHP, and MySQL here.

Since I put together that instruction 4 years ago, it no longer works with the newer version of PHP 7.3 and MySQL 8.0.13. So here is the updated instruction:

Step 1: Install Apache 2.4.37

bin>httpd.exe -k install
  • Open browser and type “localhost” to see if it works.

Step 2: Install PHP 7.3

  • Download PHP 7.3 (VC15 x86 Thread Safe)
  • Extract to C:\php
  • Re-name ” C:\php\php.ini-development ” to “php.ini”
  • Open “php.ini” in Notepad++ and search for extension_dir = “ext” and uncomment it (under on Windows). Then change it to extension_dir = “C:\php\ext”
  • Add the following to C:\Apache24\conf\httpd.conf under #LoadModule xml2enc_module modules/mod_xml2enc.so .For PHP 7 do something like this:
LoadModule php7_module "c:/php/php7apache2_4.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"
  • Add index.php in httpd.conf as below
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
  • Restart Apache
  • Create an “index.php” file and place it in “htdocs”
  • Open it in browser “localhost/index.php” to see if it works.

Step 3: Install MySQL 8.0.13

  • Download MySQL(Windows (x86, 32-bit), MSI Installer)
  • Install MySQL using the default option
  • Open C:\php\php.ini and uncomment as the following
extension=curl
extension=gd2
extension=mbstring
extension=mysqli
extension=openssl
extension=pdo_mysql
  • Check connectivity of PHP and MySQL, create “mysqltest.php” in “htdocs” and open it in browser
<?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?> 

Step 4: Enable Curl

If you run into the following curl issue, you can update the Path to resolve that issue

Fatal error: Uncaught Error: Call to undefined function curl_init()

In Control Panel -> search and view Advanced System Settings -> Click on Environment Variables… -> Under System variables, find Path -> Add c:\php