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

For PHP to work we first get a version of the Apache web server. You can find the latest versions at (Version 2.4.18 at time of writing). We can choose between a 32 and 64 bit edition, both compiled with Visual Studio 2015 (VC14). As PHP 7 is fully compatible to 64 bit, download the latter.

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

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

Just today Cal Evens posted on Twitter the immediate availability of PHP 7.0.1 with a link to the sources. As usual Windows binaries are listed seperately on There are multiple versions available - be sure to download a version that’s compatible with the former components: meaning a thread safe VC14 binary for 64 bit systems. The difference to Non Thread Safe bnaries are explained in the hand sidebar.

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)


All files and folders are set. Time to configure the web server and PHP to play nicely together. We’ll use relative paths to create a portable installation. So you will be able to copy it to a different location on your hard drive or even a USB stick.

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

There you go, we are ready for a test drive. Open the command line (Win+R) and change the directory to the Apache binary folder

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

What about the database?

MySQL runs seperately from the Apache server. The community edition of the database server is freely available at the MySQL Dev Site. In consistency with all other components choose a 64 bit version and download the ZIP archive instead of the MSI installer. Although indicated you don’t have to register or login. An unobstrusive “No thanks, just start my download” link is situated further down the page. Once finished extract the contents of the downloaded archive to a mysql folder within c:\wamp. This is the final structure of our WAMP environment

+- 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.

Thanks for reading and have fun with your dev environment. Best way to stay tuned is following us on Twitter. Comments are very welcome.

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store