Installation & Setup
On this page
Two Ways to Run PHP
You can run PHP through a web server (Apache/Nginx + PHP-FPM) or directly via the CLI. You will use both: web server for real web requests, CLI for scripts, cron jobs, and tooling.
Check Your PHP Version
After installation, verify that PHP is available and confirm the version.
php -v
Run a Simple CLI Script
Create a file named hello.php and run it from the terminal.
<?php echo 'Hello from PHP CLI' . PHP_EOL;
php hello.php
Run a Local Development Server
PHP includes a built-in dev server (not for production). It's great for quick tests.
php -S 127.0.0.1:8000 -t public
Production Note
In production you typically run PHP via PHP-FPM behind Nginx (or Apache). Combine it with OPcache for performance, and keep environment configuration separate from code.