Setup Your Dev Environment on Windows - with PHP 7 & MySQL 5.7

Seven currently is the magic number for all fans of the good old LAMP stack. Oracle released the general availability release of MySQL 5.7 in late octobre and PHP 7 just hit the road - leapfrogging from 5.6 and leaving out version 6.

Time goes by and newer PHP / MySQL versions are available. We updated our story to include versions 8 here.

It’s almost a tradition for us to write tutorials on how to install new PHP or MySQL versions on Windows. We repeatedly did so on and it’s a pleasure to continue after we started our own company OneBitAhead GmbH earlier this year.

Starting with Apache

Download Options for Apache

The downloaded archive contains a folder named Apache24, just extract all of its content to c:\wamp (We chose the name wamp as acronym for Windows-Apache-MySQL-PHP). After extraction the apache web server software our folder should look like this:

+- wamp
+- apache
+- all the apache stuff like bin, conf, etc...

For a properly working web server we need Microsofts “Visual C++ Redistributable for Visual Studio 2015″ to be installed as runtime. Grab a 64 bit copy from

Download Options for VC14 Redistributables

Let’s leave the server unconfigured for a minute until we’ve downloaded PHP. We will configure both of them together later on.

Add PHP to the server

After downloading the PHP binary it’s time to create a handful of new subfolders in our c:\wamp directory. Obviously we need a folder named php where you can extract all contents of the downloaded PHP archive. And while we’re on it, add two more folders directly under c:\wamp: htdocs for all our scripts and tmp for temporary files like sessions. When you’re done our wamp directory has grown to:

+- wamp
+- apache
+- all the apache stuff like in, conf, etc...
+- htdocs (still empty)
+- php
+- all the php stuff like ext, extras and logs
+- tmp (still empty)


Let’s start with the file c:\wamp\php\php.ini. It’s not there yet but we have to make a copy of php.ini-development in the same location. First of all we configure the extensions. Search for “extension_dir“ and don’t be shocked to find more than one occurence. None of those occurences is active but commented out by default. Comments in the php.ini start with semicolon (;). Look for a the “; On Windows:” right before the one of those extension_dir lines. Switch ; extension_dir = “ext” to
extension_dir = “..\..\php\ext”
and please note: the semicolon at the beginning of the line has been removed to uncomment the declaration! The directory is defined relatively to the Apache configuration file httpd.conf. With the extension dir set up we can now activate available extensions by uncommenting its declarations. Head over to a block of about 20 lines starting with ;extension=. Choose curl, gd2, mbstring, mysqli, sockets and xmlrpc for now.
Last but not least we define a directory for temporary files and session files. Assign “..\tmp” to both upload_tmp_dir as well as session.save_path. And don’t forget to uncomment the declarations as well.

The Apache web server configuration file is named C:\wamp\apache\conf\httpd.conf. The following list contains all necessary changes. Search for the String before the -> and change them to the new value behind the arrow:

  • ServerRoot “c:/Apache24″ –> ServerRoot “..”
  • Listen 80 –> Listen 82
  • LoadModule php7_module “../php/php7apache2_4.dll” (at the end of the LoadModule directives situated om the middle of the file)
  • #ServerName –> ServerName localhost:82
  • Require all denied (within <Directory />) –> Require all granted
  • DocumentRoot “c:/Apache24/htdocs” –> DocumentRoot “../htdocs”
  • <Directory “c:/Apache24/htdocs”> –> <Directory “../htdocs”>
  • DirectoryIndex index.html –> DirectoryIndex index.php index.html
  • AddType application/x-httpd-php .php (at the end of directive <IfModule mime_module>, just behind AddType application/x-gzip .gz .tgz)
  • PHPIniDir ../php (add at the end of the file)

To avoid conflicts with other applications running on the default port 80 (e.g. Skype) we instead use the port 82. It’s important to add the port number to local URLs in your browser like http://localhost:82/ and not use http://localhost/. Feel free to use any other free port instead, you often see 8000, 8080 or such in comparable cases.

Most importantly we’d like to point out that this tutorial server is for testing purposes only. Do not use it in production because the configuration is unsafe by definition (“Require all granted”) which is okay on a dev sever.

Running tests

cd c:\wamp\apache\bin



to get the server started. All is good when there is no subsequent output but the prompt stays silent. In case of any onscreen messages something is wrong -> Google is your friend while debugging. But let’s assume everything is fine. Create a new file named phpinfo.php within the htdocs directory with the following one-liner content:

<?php phpinfo(); ?>

The first line begin with

PHP Version 7.0.1
Congratulations on a PHP 7 powered web server

What about the database?

+- wamp
+- apache
+- htdocs
+- mysql
+- php
+- tmp

There is a file named my-default.ini in the mysql directory. Rename it to my.ini for configuration. The easiest way to initialize MySQL is to change into the mysql folder and execute

bin\mysqld --initialize --console

During init the server creates a data directory (as direct subdirectory in c:\wamp\mysql\data) and populates the system database. It also creates a root account with a random yet expired password. The console output shows the default password (in a WARNING line), hence the — console option.

In case the data directory is not created where it belongs copy the wrongly created files to the right place an initialize again with basedir and datadir options set in the prompt.

bin\mysqld --initialize --basedir=c:\wamp\mysql --datadir=c:\wamp\mysql\data --console

After that you can start your server by invoking bin\mysqld and connect using the root account (in another command line) and the default password.

bin\mysql -uroot -p

The thing is: you can’t do anything until you change the expired password. Fortunately this is a one-liner as well.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourPassword';

That’s it.

The tech staff of OneBitAhead GmbH, putting the web stack to work. Here to discuss daily bits & bytes. #javascript #nodejs #webcomponents #rdbms #php