In this post I’m going to show you how to install and configure the latest versions of PHP 7, Apache 2.4 httpd server, and MySQL 8 on Microsoft Windows 10 operating system.
If you have Windows 7 or Windows 8 you should not have any problem following this instruction.
Go ahead and launch powershell with admin rights, now paste the following code in your powershell and hit enter one by one.
We are going to install chocolatey (a package installer for Windows ) that will let us install PHP and Apache server with two commands on the fly, that will save us time and on behalf of us it will go ahead and configure them as well.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
The second command may take a bit longer depending on your operating system.
Now you will have to relaunch the powershell or the command prompt with admin right. We are going to install PHP, the latest version with command prompt. Chocolatey you will download the latest version of PHP, extract it, install it and set the variable path as well.
Install PHP – Latest
choco install php -y --package-parameters='"/ThreadSafe ""/InstallDir:C:\tools"""'
This shouldn’t take a long time. You just wait and watch and once it says installed package one of one. You just need to check the version of PHP that has been installed. simply launcher command prompt and type php -version and hit enter.
There you have it; the latest version of PHP installed and configured for you on the fly.
Similarly we are going to install Apache http server with chocolatey. Launch your powershell/CMD with admin rights.
Install Apache – Latest
choco install apache-httpd -y --params '"/installLocation:C:\tools"'
You just wait and watch until it finishes the installation. It may take up to 2-3 minutes. After the installation, we need to start the httpd service.
Simply add this following folder path to system variable path and launch your command prompt with admin right.
Let’s install the httpd service, Type the following command in the command prompt without admin rights.
httpd -k install
Perfect now we need to configure our httpd config file for our PHP files and module. Locate the following httpd.confi file under the following directory and open it with your preferred text editor.
Add the following lines of code at the very bottom of httpd.conf file
LoadModule php7_module "c:/tools/php74/php7apache2_4.dll" <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> PHPIniDir "C:/tools/php74"
Now we need to restart the Apache server type the following command in command prompt with admin right to restart the Apache httpd server.
httpd -k restart
You try to load localhost:8080 in your preferred Browser.
Now we need to check if PHP can be read with this Apache server, so create info.php file and type following PHP command and save the file. C:\tools\Apache24\htdocs/info.php
Let’s go ahead and install MySQL 8 on Microsoft Windows 10 with chocolatey on the fly. Copy and paste the following command in command prompt with admin rights and hit enter.
Install MySQL – Latest
choco install mysql -y
Once this MySQL is installed with chocolatey you simply have to launch your command prompt and type the following command to access your MySQL server.
mysql -u root -p
Do not type any password, just hit enter and you will be in mysql shell.
There you have it.. PHP, Apache and MySQL installed and configured on Windows Desktop/server.