How To Install PHP 8 On Ubuntu 25.04 (Step-by-Step Guide for Beginners)
To install PHP on Ubuntu 25.04 ("Plucky"), the current stable version available via apt is PHP 8.4, here is step-by-step instruction how to get it up and running :
🔧 1. Update AND Install PHP 8.4
Installs PHP 8.4 (default), the Apache module, CLI tools, and common extensions.
sudo apt update
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-gd php-mbstring php-xml php-zip -y
To confirm the install :
php -v
🧩 2. (Optional) Install Additional Extensions
For advanced needs, append whichever you require. For example :
sudo apt install php8.4-intl php8.4-pgsql php8.4-zip
And restart Apache :
sudo systemctl restart apache2
This ensures new modules are recognized.
🗃 3. Plug Into Your Web Server
With Apache :
- The Apache module was already installed.
- To test, create a PHP info page :
echo "<?php phpinfo();" | sudo tee /var/www/html/info.php
- Visit http://YOUR_SERVER_IP/info.php to view PHP settings.
- Clean up after testing :
sudo rm /var/www/html/info.php
- Restart Apache to apply changes :
sudo systemctl restart apache2
🔐 4. Verify Security Updates & PHP Version
Ubuntu now ships with PHP 8.4 and maintains it with patches (e.g., version 8.4.5+ fixes found in March 2025). You don't need external PPAs unless you need older/newer PHP major versions.
✅ Summary
| ---- | ------------------------------------------- | ---------------------------------- |
| Step | Command | Purpose |
| ---- | ------------------------------------------- | ---------------------------------- |
| 1 | sudo apt update && sudo apt install php | Installs PHP 8.4 & core extensions |
| 2 | php -v | Confirms version |
| 3 | Create info.php & visit in browser | Checks integration with Apache |
| 4 | sudo rm info.php && restart apache2 | Cleanup and final restart |
| ---- | ------------------------------------------- | ---------------------------------- |
Tags :