You can either install some local servers like xampp or wamp that comes with a lot of things that you may or may not need, but if you want a full control of what version of php you want to install on your machine I strongly recommend to install it locally, and that's what I'm gonna show you in this article.
This tutorial is working for those systems:
- Windows 7 (x86 and x64)
- Windows 8 (x86 and x64)
- Windows 10 or latest (x86 and x64)
Let's go now and install php on windows 10.
Choose PHP version
First of all let's go to php.net and download the version of php that you want to install on your machine, currently the latest version stable is PHP 7.4.12, so if you're reading this article in the future and their is a new version of php try to install the latest, generally you'll not have any problem.
While I'm on this page I'm gonna click on Windows downloads which will redirect me to windows.php.net where you'll find that there is 4 versions of php two of for x64 systems and two for x86 bit systems and also there is Non Thread Safe version and Thread Safe version, for now you can use what want it'll not make any big deal it's just something related to the server.
I'm gonna choose VC15 x64 Non Thread Safe and click on the Zip link:
Once you click on the link it'll download an archive compressed files, inside this files you'll find a different files that allow PHP to work correctly.
Install PHP on Windows
Now that zip file that you have been downloaded you need locate it somewhere on your windows system, note that you can put it wherever you want it doesn't matter.
For me I'm gonna make it my C: drive, I'm gonna create an src/ folder and a new folder inside which I'm gonna name it php/ so here is how it looks C:\src\php, now you need to extract the downloaded zip file inside this new created folder.
PHP Configuration on windows
now it's time to make some configuration to our installed php on our machine let's go.
add php to path windows
When to set php path in windows 10 environment variables, so that when we tap
php on our command line the system knew in which folder will look for the
php.exe which we put in the
For that we need to change environment variables in the system, tap
windows + s on your keyboard and look for this term
environment click on Edit the system environment variables.
Once you click on that a new popup window will appear:
Click on Environment variables button and a new window will appear, choose the Path from the list of user variables and click on Edit... button, it's variable that helps windows to know where to find executable files.
Now we'll add a new path which will be the one where install php which is in my case:
Once you add this path hit the Ok button for all of opened windows.
Check if php is installed
If you add the path to php folder like I did above, and open the command line by looking for cmd on windows search and type
Sadly if you're on newly installed windows on your machine or you don't install a lot of stuffs you'll face this problem:
the code execution cannot proceed because vcruntime140.dll was not found reinstalling the program
Don't worry this kind of errors are totally normal, because PHP to work correctly you need very particular dependency which they said in the official website of php:
More recent versions of PHP are built with VC15 or VS16 (Visual Studio 2017 or 2019 compiler respectively) and include improvements in performance and stability.
Since I downloaded VC16 version I need to download Visual C++ Redistributable
The VC15 and VS16 builds require to have the Visual C++ Redistributable for Visual Studio 2015-2019 x64 or x86 installed
Now click on the link x64 they give you like bellow:
Download the executable file and accept the license terms and conditions and start the installation.
This may take some time it depends on your internet connection. once the installation is done click on the Ok button.
Now if you go back and open the command line and tape
You can see that I have php 7.4.13 installed on windows successfully.
Now you can start developing with php.