Categories
PHP Programming

Installing PHP on Windows

What is PHP?

PHP is known to be one of the most commonly used server-side programming language on the web. It provides an easy to master with a simple learning curve. It has close ties with the MySQL database, and various libraries to cut your development time.

Two Ways to install PHP locally

There are several ways that we could install PHP locally. Here i have added two of the most common ways to install PHP as shown below.

  1. Installing a Web Server (XAMPP, WAMP etc)
  2. Implementing via PHP Installer
Installing a Web Server

There are many all-in-one packages are available for Windows and other OS’s which comes with Apache, PHP, MySQL and other applications as a single file installer, e.g. XAMPP, WampServer, MAMP etc. There is no any issue in going with these packages, however manually installing Apache and PHP will help you to have more control and access to its configuration options.

XAMPP :
https://www.apachefriends.org/index.html

WampServer :
https://www.wampserver.com/en/

MAMP :
https://www.mamp.info/en/windows/

Implementing via PHP Installer

It provides several benefits for backing up, reinstalling, or moving the web server can be executed easily in a short amount of time and it provides more control over PHP and Apache configuration. In the Manual Installation, you need to configure several steps in order to install PHP successfully.

Step 1 : Download the PHP package & Extract THE FILES

Get the PHP version 8.0 or later (x64 Thread Safe) package zip file via navigating under the windows downloads URL mentioned in the link below.

https://www.php.net/downloads.php.

After, downloading the zip successfully to your PC, create a folder as “PHP” in any drive and extract the PHP package files into it.

STEP 2 : CONFIGURE PHP

Initially php.ini file doesn’t exist inside the php package files. so copy {drive_name}:\php\php.ini-development and rename it as {drive_name}:\php\php.ini whereas the default configuration provides a development setup.

To uncomment a setting inside the php.ini file you need to remove a leading semicolon (;). Uncomment the following lines to enable the required extensions whereas the following extensions are mostly required by many PHP frameworks and for other operations.

extension=curl extension=gd extension=mbstring extension=pdo_mysql
Step 3 : Add PHP to The environment variable

To access PHP globally at your PC add the PHP package path by following the steps below.

  • Step 1: Click the Windows Start button and type β€œenvironment”.
  • Step 2: Click Edit the system environment variables. Select the Advanced tab, and click the Environment Variables button.
  • Step 3: Scroll down the System variables list and click Path followed by the Edit button.
  • Step 4 : Click New and add {drive_name}:\php:

NOTE: You are not required to reboot the PC, but you may need to close and restart any cmd terminals if you have opened before.

STEP 4 : Test a PHP file

Create a new file named index.php and add the following lines of codes and save it.

<?php phpinfo(); ?>
Code language: HTML, XML (xml)

Run the PHP file by entering the following command in CMD where you have created the index.php file.

php index.php
Code language: CSS (css)

Leave a Reply

Your email address will not be published. Required fields are marked *