Installing PHP
This guide explains how to install PHP on different operating systems.
Requirements
- Basic command-line knowledge
- Administrator / sudo access
- Internet connection
Installation on Windows
1. Download PHP
- Go to the official PHP downloads page: https://www.php.net/downloads
- Click Windows downloads
- Download the latest Thread Safe ZIP package (x64)
2. Extract PHP
Extract the ZIP file to:
C:\phpRename
php.ini-developmenttophp.ini
3. Add PHP to PATH
Open System Properties → Environment Variables
Edit Path under System variables
Add:
C:\phpClick OK and restart your terminal
4. Verify Installation
bash
php -vYou should see the PHP version output.
Installation on macOS
Option A: Using Homebrew (Recommended)
bash
brew install phpVerify:
bash
php -vOption B: Manual Installation
- Download PHP from https://www.php.net/downloads
- Extract and follow the provided instructions
Installation on Linux
Ubuntu / Debian
bash
sudo apt update
sudo apt install php php-cli php-commonFedora
bash
sudo dnf install php php-cliArch Linux
bash
sudo pacman -S phpVerify:
bash
php -vConfigure PHP
Edit php.ini
Find your active configuration file:
bash
php --iniCommon settings:
ini
memory_limit = 256M
upload_max_filesize = 20M
post_max_size = 20M
date.timezone = Asia/ManilaEnable Common Extensions
Edit php.ini and uncomment:
ini
extension=pdo_mysql
extension=mbstring
extension=openssl
extension=curlRestart your web server after changes.
Using PHP Built-in Server
bash
php -S localhost:8000Open:
http://localhost:8000Project Structure Example
text
my-project/
├── index.php
├── composer.json
└── vendor/Verify with a Test File
Create index.php:
php
<?php
phpinfo();Visit it in your browser to confirm PHP is working.