PHP has far been the preferred language for programming web backends. It’s supported by most if not all local webserver packages as well.
If you decide to download and install a local web server stack like WAMP or XAMPP, PHP will be installed locally alongside it. However, if for whatever reason you need to install PHP manually, here’s how.
Also read: How to install Java on Windows 10?
Installing PHP on Windows 10
Now while there’s an installer available on the official PHP website, we suggest that you install it manually as it’s more stable and avoids running into any conflicts if in case you have any webservers installed on your PC.
Step 1: First up, we need to download the zip file for the latest PHP release. At the time of writing this article, the latest release is 7.4.11
Step 2: Once you’ve downloaded the zip package, extract it in the root directory of your C:/ drive in a folder called PHP7
Step 3: Go inside the PHP7 folder you just created and look for a file called php.ini-development. Copy and paste this file in the same directory and rename it to php.ini.
Step 4: We’re now going to make some configuration changes in the php.ini file. Note that the entire file is written in the form of comments which means there’s a ‘;’ preceding each line. You’re going to have to remove it wherever applicable. Open it in notepad and make the following changes
- Define the extension directory: Look for the line extension_dir and change it to extension_dir = “C:/PHP7/ext”
- Enable extensions: Although this will depend on the libraries you end up using, these should cover all the basics
- Configure the mail() method: If you’re looking to use the PHP mail() function to send emails, You can configure it with whatever server SMTP settings you prefer.
Step 5: Now we’re going to add a path variable for our PHP installation so we can access it from the command prompt. To do so, open the Start menu and type in ‘environmental variables’.
Under the Advanced tab, click on Environment Variables.
Step 6: Under System Variables, click on Path and then Edit.
Step 7: Click on the New button. Then type in C:\PHP7 and then click OK.
And that’s about it. You’ve installed PHP on your system. You might need to restart it at this point for all the changes to take effect.
As a sanity check, fire up the Command Prompt and type in php-v to check the PHP version. You should see something like this.
Also read: How to install Python on Windows?
Someone who writes/edits/shoots/hosts all things tech and when he’s not, streams himself racing virtual cars. You can reach out to Yadullah at [email protected], or follow him on Instagram or Twitter.