Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 05 / 1953%· free preview
Introduction to PHP5/9

Installing PHP

Three ways to install
1 · macOS (Homebrew)
bash
brew install php
php -v
# PHP 8.3.x (cli) (built: ...)
2 · Linux (Ubuntu/Debian)
bash
sudo apt update
sudo apt install php php-cli php-mysql php-curl php-mbstring
php -v
3 · Windows

Easiest: install XAMPP (next lesson) — bundles PHP, Apache, MySQL together. Otherwise grab the PHP zip from https://windows.php.net and add it to your PATH.

Running PHP without a web server

PHP ships with a built-in dev server — perfect for learning.

bash
mkdir my-site && cd my-site
echo '<?php phpinfo(); ?>' > index.php
php -S localhost:8000
# Open http://localhost:8000 → full PHP info page

That's the entire dev setup. No Apache config, no nginx, no docker. Hit Ctrl+C to stop.

<!-- ck:os-install -->
OS-specific Install Steps
Windows
powershell
# Easiest: install XAMPP (Apache + PHP + MySQL)
winget install -e --id ApacheFriends.Xampp.8.2
# Or pure PHP via Chocolatey:
choco install php
php -v
macOS
bash
brew install php@8.3
brew link php@8.3 --force --overwrite
php -v
Linux (Ubuntu / Debian)
bash
sudo apt update
sudo apt install -y php-cli php-mbstring php-curl php-xml
php -v
Linux (Fedora / RHEL)
bash
sudo dnf install -y php-cli php-mbstring php-curl php-xml
php -v
Verify
bash
echo '<?php echo "Hello, PHP!" . PHP_EOL;' > hi.php
php hi.php
Composer (PHP package manager)
bash
# All OSes (after PHP installed):
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer       # macOS / Linux
composer --version
AI-powered recap

Quick recap quiz?

We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.

Ready to move on?
// feedback.matters()
Did this lesson help you?