Jan 29, 2026
```
## Chapter 1: Install PHP (Windows / macOS / Linux)
Goal of this chapter: install PHP, confirm it works in the terminal, and avoid “it installed but nothing runs” problems.
### A) Windows (two good options)
#### Option 1: Install only PHP (lightweight)
1. Download the latest PHP zip for Windows from the official PHP site (choose the non-thread-safe build if you will use PHP-FPM later; for learning, either is fine).
2. Extract it to a simple path, for example:
`C:php`
3. Add `C:php` to your PATH:
- Start Menu → search “Environment Variables”
- Edit the PATH variable → New → `C:php`
4. Open PowerShell and verify:
```bash
php -v
php -m
```
If `php -v` works, you’re ready.
#### Option 2: Install XAMPP (easy local web server)
If you want Apache + PHP + MySQL in one installer, XAMPP is the simplest. Install it, start Apache, and put your PHP files in the `htdocs` folder.
When to use which?
- “Only PHP” is perfect if you want CLI + built-in server and a clean setup.
- XAMPP is convenient if you want Apache and MySQL quickly.
### B) macOS (Homebrew)
```bash
brew update
brew install php
php -v
```
### C) Linux (Ubuntu/Debian example)
```bash
sudo apt update
sudo apt install php php-cli php-mbstring php-xml php-curl php-sqlite3
php -v
```
Different distros use different package managers, but the idea is the same: install `php` and a few common extensions.
---
### Setup details: php.ini and extensions (small things that save hours)
Sometimes PHP is installed, but features are missing (JSON, cURL, mbstring, database drivers). That usually means: the extension is not installed or not enabled.
### Find your active php.ini
```bash
php --ini
```
This prints which `php.ini` file PHP is actually using.
### See which extensions are loaded
```bash
php -m
```
If you don’t see something like `curl` or `mbstring`, install/enable it.
On Linux you usually install extra extensions using packages (example):
```bash
sudo apt install php-curl php-mbstring
```
On Windows (zip install), you typically enable extensions in `php.ini` by removing the `;` in front of the line, and making sure `extension_dir` points to the correct folder.
---