Paridhi SolutionsBlog

How to Install PHP 8.4 on Ubuntu 24.04 LTS (Complete Step-by-Step Guide)

Learn how to install PHP 8.4 on Ubuntu 24.04 LTS, install required PHP extensions, configure php.ini, verify the installation, and prepare your server for modern PHP applications.

2026-07-02
6 min read read
How to Install PHP 8.4 on Ubuntu 24.04 LTS (Complete Step-by-Step Guide)
How to Install PHP 8.4 on Ubuntu 24.04 LTS (Complete Step-by-Step Guide)

How to Install PHP 8.4 on Ubuntu 24.04 LTS

PHP is one of the most widely used server-side programming languages for web development. Popular platforms such as Magento, WordPress, Laravel, and many custom PHP applications depend on a properly configured PHP environment.

In this guide, you'll learn how to install PHP 8.4 on Ubuntu 24.04 LTS, install commonly used PHP extensions, configure PHP for better performance, verify the installation, and troubleshoot common issues.


What You'll Learn

By the end of this tutorial you'll know how to:

  • Install PHP 8.4
  • Install commonly required PHP extensions
  • Verify your PHP installation
  • Configure PHP settings
  • Restart PHP-FPM
  • Troubleshoot common PHP issues

Prerequisites

Before starting, ensure you have:

  • Ubuntu 24.04 LTS
  • A user with sudo privileges
  • Internet connectivity
  • Terminal access

Step 1 — Update Your Ubuntu System

Before installing new software, update your package list and installed packages.

bash
sudo apt update
sudo apt upgrade -y

Keeping your system updated ensures you're installing the latest available packages and security fixes.

You can also verify your Ubuntu version.

bash
lsb_release -a

Example:

text
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble

Step 2 — Install Required Packages

Install the package required to manage repositories.

bash
sudo apt install software-properties-common -y

Step 3 — Add the PHP Repository

Ubuntu's default repositories may not always provide the latest PHP release. A commonly used repository for newer PHP versions is maintained by Ondřej Surý.

Add the repository:

bash
sudo add-apt-repository ppa:ondrej/php

Update package information:

bash
sudo apt update

Step 4 — Install PHP 8.4

Install PHP.

bash
sudo apt install php8.4 -y

After installation, verify the installed version.

bash
php -v

Example output:

text
PHP 8.4.x (cli)
Copyright (c) The PHP Group
Zend Engine v4.x

Step 5 — Install Common PHP Extensions

Most PHP applications require additional extensions.

Install the commonly used extensions:

bash
sudo apt install \
php8.4-cli \
php8.4-common \
php8.4-fpm \
php8.4-bcmath \
php8.4-curl \
php8.4-gd \
php8.4-intl \
php8.4-mbstring \
php8.4-mysql \
php8.4-opcache \
php8.4-readline \
php8.4-soap \
php8.4-xml \
php8.4-xsl \
php8.4-zip \
php8.4-sockets -y

PHP Extension Overview

ExtensionPurpose
bcmathMathematical calculations
curlHTTP requests
gdImage processing
intlInternationalization
mbstringUTF-8 string handling
mysqlMySQL database connectivity
soapSOAP web services
xmlXML parsing
xslXML transformations
zipArchive extraction
socketsNetwork communication
opcacheImproves PHP performance

Step 6 — Verify Installed Extensions

Run:

bash
php -m

Verify that important modules such as the following are available:

  • curl
  • intl
  • mbstring
  • mysql
  • soap
  • xml
  • xsl
  • zip
  • gd
  • opcache

Step 7 — Find the Active PHP Configuration File

Display the active configuration.

bash
php --ini

Example output:

text
Loaded Configuration File:
/etc/php/8.4/cli/php.ini

For PHP-FPM you'll typically edit:

text
/etc/php/8.4/fpm/php.ini

Open the file:

bash
sudo nano /etc/php/8.4/fpm/php.ini

Step 8 — Recommended PHP Configuration

The following settings are suitable for many PHP applications and provide a good starting point.

ini
memory_limit = 2G
max_execution_time = 1800
max_input_time = 1800
upload_max_filesize = 64M
post_max_size = 64M
date.timezone = Asia/Kolkata
SettingValue
memory_limit2G
max_execution_time1800
upload_max_filesize64M
post_max_size64M
timezoneAsia/Kolkata

Adjust these values based on your application's requirements.


Step 9 — Restart PHP-FPM

After making configuration changes, restart PHP-FPM.

bash
sudo systemctl restart php8.4-fpm

Check its status.

bash
sudo systemctl status php8.4-fpm

You should see:

text
Active: active (running)

Step 10 — Verify the Default PHP Version

If multiple PHP versions are installed, verify which version is active.

bash
php -v

If needed, switch the CLI version.

bash
sudo update-alternatives --config php

Troubleshooting

PHP Command Not Found

text
php: command not found

Possible solutions:

  • Verify PHP is installed.
  • Restart your terminal.
  • Check your PATH configuration.

Incorrect PHP Version

Verify the installed version.

bash
php -v

If multiple versions exist, update the active version.

bash
sudo update-alternatives --config php

Missing Extensions

List installed extensions.

bash
php -m

Install any missing extension.

Example:

bash
sudo apt install php8.4-intl

PHP-FPM Service Won't Start

Check its status.

bash
sudo systemctl status php8.4-fpm

Review logs.

bash
sudo journalctl -u php8.4-fpm

Frequently Asked Questions

How do I check my PHP version?

Run:

bash
php -v

Where is php.ini located?

Find the active configuration file.

bash
php --ini

Can I install multiple PHP versions?

Yes.

Ubuntu allows multiple PHP versions to coexist. You can switch the active CLI version using:

bash
sudo update-alternatives --config php

How do I list installed PHP extensions?

Run:

bash
php -m

Do I need PHP-FPM?

If you're using Nginx, PHP-FPM is the standard way to process PHP requests and is recommended for production deployments.


Conclusion

Congratulations! 🎉

You've successfully installed PHP 8.4 on Ubuntu 24.04 LTS, installed commonly used extensions, configured PHP, and verified that your installation is working correctly.

Your server is now ready for PHP-based applications and is well prepared for the next steps in setting up a complete development environment.


What's Next?

Continue with the next guide in our series:

➡️ How to Install Composer on Ubuntu 24.04 LTS

Composer is the dependency manager used by modern PHP applications such as Magento, Laravel, and many other frameworks.

Share this article

Tags

PHPPHP 8.4UbuntuUbuntu 24.04LinuxMagento

Written by

Paridhi Solutions

We help businesses build scalable Magento, React, Next.js, Laravel and custom web applications. Our blog shares practical development guides, performance tips, and real-world solutions from client projects.

Adobe CommerceMagentoReactNext.jsLaravel

Related Articles

🚀 We're Just Getting Started

Join the Paridhi Solutions Developer Community

We're actively publishing practical tutorials covering Magento, Adobe Commerce, React, Next.js, PHP and WordPress. Join our newsletter and be the first to know whenever a new guide is published.

📚 Practical Tutorials⚡ Performance Tips💼 Real Project Experience
✓ New tutorials every week✓ No spam✓ Unsubscribe anytime