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

Starting with Apache

For PHP to work we first get a version of the Apache web server. You can find the latest versions at http://www.apachelounge.com/download/ (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.

Download Options for Apache
C:
+- wamp
+- apache
+- all the apache stuff like bin, conf, etc...
Download Options for VC14 Redistributables

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 windows.php.net. 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.

C:
+- 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)

Configuration

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.

  • 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 www.example.com:80 –> 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)

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
httpd
<?php phpinfo(); ?>
PHP Version 7.0.1
Congratulations on a PHP 7 powered web server

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

C:
+- wamp
+- apache
+- htdocs
+- mysql
+- php
+- tmp
bin\mysqld --initialize --console
bin\mysqld --initialize --basedir=c:\wamp\mysql --datadir=c:\wamp\mysql\data --console
bin\mysql -uroot -p
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.

--

--

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
OneBitAhead

OneBitAhead

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