Home / Linux / How to Install PHP and Check Its Version

How to Install PHP and Check Its Version

Install PHP on Ubuntu/Debian or RHEL-based systems, verify the version, and check PHP-FPM status if used.

Views: 19 Unique: 16 Updated: 2026-03-20

What this is

This guide shows how to install PHP and confirm it is working.

What it is for

  • Run PHP websites (WordPress, Laravel, etc.)
  • Use PHP CLI for scripts

Prerequisites

  • SSH + sudo

Step-by-step by distribution

Ubuntu/Debian

sudo apt update
sudo apt install -y php php-cli php-fpm php-mysql

RHEL/Rocky/Alma

sudo dnf install -y php php-cli php-fpm php-mysqlnd

Verify version

php -v

Verify PHP-FPM (if installed)

sudo systemctl status php-fpm --no-pager

Conclusion

PHP is installed and you can confirm its version. Next steps: configure Nginx/Apache to use PHP-FPM.

Back to category