PHP Installation

PHP Tutorial

Here is a clear and complete guide for PHP Installation on Windows, macOS, and Linux.


PHP Installation Guide

PHP can be installed in three ways:

  1. Using XAMPP (Recommended for Beginners)

  2. Using WAMP / MAMP / LAMP

  3. Installing PHP manually

Below are the steps for each method.


🚀 1. Install PHP Using XAMPP (Beginner Friendly)

XAMPP includes: Apache Server + PHP + MySQL + phpMyAdmin

✔ Steps:

1: Download XAMPP

2: Install XAMPP

  • Run the installer

  • Select components (keep default)

3: Start Apache & MySQL

Open XAMPP Control Panel → Start:

  • Apache

  • MySQL

Step 4: Check PHP Version

Open browser and type:

http://localhost

Or open Command Prompt and check:

php -v

Step 5: Test PHP File

Create a file:

C:\xampp\htdocs\test.php

Add this code:

<?php
echo "PHP is working!";
?>

Open in browser:

http://localhost/test.php

2. Install PHP Using WAMP (Windows)

✔ Steps

  1. Download WAMP: https://www.wampserver.com

  2. Install and Launch

  3. Check PHP version:

php -v
  1. Create projects inside:

C:\wamp\www\

3. Install PHP Using MAMP (macOS)

✔ Steps

  1. Download MAMP: https://www.mamp.info

  2. Install

  3. Start Servers (Apache, MySQL)

  4. Test PHP:

http://localhost:8888

Your PHP files go inside:

/Applications/MAMP/htdocs/

4. Install PHP Using LAMP (Linux)

Ubuntu / Debian

sudo apt update
sudo apt install apache2
sudo apt install php libapache2-mod-php
sudo systemctl restart apache2
php -v

CentOS / Fedora / RHEL

sudo dnf install httpd
sudo dnf install php php-cli
sudo systemctl restart httpd
php -v

5. Manual Installation of PHP (Advanced Users)

1: Download PHP

2: Extract ZIP to:

C:\php\

3: Add PHP to PATH

  • Open System Environment Variables

  • Edit PATH → Add:

C:\php\

4: Test

Open CMD:

php -v

6. Verify PHP Installation

Create a test file:

Open in browser:

http://localhost/phpinfo.php

This shows complete PHP configuration.


Which method should you choose?

Purpose Best Option
Beginners ⭐ XAMPP
Windows-only development WAMP
macOS users MAMP
Linux users LAMP
Professional Developer Manual PHP + Composer

You may also like...