Table of Contents
Before we dig in on installing PHP on Windows 10, let’s first briefly describe what PHP is. PHP is an acronym for Hypertext Preprocessor. It’s an open-source scripting language that is executed on the server and is free to download and also to use. PHP files have an extension php.
Why do we need PHP?
PHP is the biggest and most popular blogging system on the web. With it, you can output other contents since it a server-side language rather than HTML output only. The best advantage of PHP is that it runs efficiently and is easy to learn. It is also compatible with very many servers and supports a wide range of databases.
With PHP, you can add, modify and delete your database data. It’s easy to control user access and also encrypt data. With PHP, you can send and receive cookies and generate dynamic web content. You can download PHP from their official website here.
Installing PHP on Windows 10
To begin with, try to note down the operating system version and the architecture of your CPU. You can do this by right-clicking on ‘This PC’ in explorer and select ‘properties’. You should see details similar to mine below, and you are good to go.
There are several methods you can use to install PHP on Windows 10. We will list them and give you a brief step-by-step on them, but we will mainly focus on the manual method and give a detailed step-by-step.
- Use an All-in-One package install.
- Using Docker desktop.
- Install Apache.
- Manually installing PHP
- Using Web Platform Installer
Use an All-in-One package
With this method, you will be installing Apache, PHP, MySQL, and other dependencies at once. Let’s call it a single click install where you get all the above-mentioned packages at once.
This includes XAMPP, WampServer, and Web.Developer. These are usually very simple and easy to install, but using them will not allow learning and understanding of all the configurations of the systems as most of it is done automatically. They can be downloaded from the internet, and the installation can be self-taught.
Docker Desktop
This method tops the list of the best setups for PHP environment development. What Docker does is to create a wrapper, also called a container, around pre-configured application dependencies like Apache, PHP, MySQL, and most web software.
This container resembles a full Linux virtual machine but lighter. You need to install Docker Desktop on Windows 10 and then easily download, configure, and run Apache and PHP.
Let’s discuss briefly how this can be achieved using the Docker desktop. You can download Docker Desktop from here. Download the .exe file and run on it your machine. It is just like any other application.
Install Apache
This is not mandatory, and you can skip it if you choose to. You can download the latest version of Apache from https://www.apachelounge.com/download/ extract its Apache24 folder to the root of your Disk C drive. You will need to install Visual C++ Redistributable for the Visual Studio version between 2015 to 2019.
Open the command prompt and start Apache with cd C:\Apache24\binHttpd
Accept the firewall exception before the server starts to run.
To change or configure Apache, go to C:\Apache24\conf\httpd.conf
The web server root folder is located at C:\Apache24\htdocs. Initially, it contains a single index.html file with the “It works!” message.
Install PHP manually
This will be our main topic of discussion and will be more detailed compare to the ones above. By the end of it, you should be able to install, configure and use PHP without any problems easily.
The benefit of manual installation is that it offers backing up, and moving the webserver is quick and simple. By this method, you have full control.
Now you might have skipped the above methods or read them, but I want you to know that this is the easiest and quickest way to install PHP.
Step by step procedure
Step 1: Downloading the PHP files
First, you need to download the latest version of PHP that will be in zip form. You can download it from here www.php.net/downloads.php
Step 2: Extracting the files
You will then create a PHP folder in the root of Disk C or your primary Disk where you want to install PHP. Extract the contents of the zip file into this folder. PHP can be installed on any Disk in your computer anywhere but referencing will have to be done for it to work. So unless you know how to do it, I advise you to follow the steps to the latter.
Step 3: Configuring the php.ini file
Now we have to find a file name ‘php.ini-development’ and make a copy. Rename this copy ‘php.ini’.
Proceed to open php.ini on a notepad to make a few changes. On the notepad, find ‘extension_dir’ and remove the semicolon (;) on extension_dir=”ext” to remove the comment.
Once you are done with that, you are to enable some vital extensions by scrolling down. Locate the extensions which are listed and enable those that you will use. In my example below, the enabled ones are essential for performing most of the functions. But remember, my list may differ from yours.
Step 4: Adding Path Environment Variable
Here is the final bit before you get back to building your project with PHP. Open the control panel on your computer and search for ‘variable’. Click on ‘Edit the system environment variables’ and then click ‘environment variables. Proceed to select ‘path’ from system variables and then click ‘Edit’. Because we want to add a path, click ‘new’ and then ‘C: php’.
To finalize, go to system variables and click new, add phprc as the name and C:\php as for the value, and click OK.
Adding the path and system variable basically marks the end of the installation process, but you have to finalize by restarting for the changes to take effect.
To see the version you have just installed on your computer, open the command prompt and type php-v. From here on, you are free to do with PHP any project you want with the ease and simplicity that comes with it.
You can also play around with php-i to get more information about the PHP you have just installed.
Conclusion
Hopefully, this article has persuaded you regarding the power of PHP. You have seen a portion of the significant highlights of the language and read contentions why PHP is superior to its numerous rivals. PHP is an awesome language and very famous for writing dynamic web pages, and remember, it is open source. Thus, there are communities of developers that can be hired or consulted for the best creations when it comes to the use of PHP. It is platform-independent, and the rate of loading is remarkable compared to other programming languages.