Install PHP and Run Your First Script
Install PHP, check versions, and run your first PHP file locally step by step.
Emily Carter
October 17, 2025
4.1k166
Let’s set up PHP so you can run code on your own machine.
Step 1: Install PHP
On Windows
Download from php.net and add PHP to PATH.
On macOS (Homebrew)
brew install php
On Linux
sudo apt install php
Step 2: Check installation
php -v
You should see the PHP version.
Step 3: Create your first file
Create a file: index.php
<?php
echo "My first PHP app!";
?>
Step 4: Run it
From terminal:
php index.php
Or using built-in server:
php -S localhost:8000
Then open:
http://localhost:8000
Next: PHP syntax basics and how PHP mixes with HTML.
#PHP#Setup#Beginner