How to Install PHP 8.4 on Ubuntu 24.04

Websolutionstuff | Feb-18-2025 | Categories : PHP

As a developer, keeping my PHP version up to date is essential for performance and security. In this guide, I’ll show you how to install PHP 8.4 on Ubuntu 24.04, configure it for Apache or Nginx, and install necessary extensions.

Whether I’m setting up a new server or upgrading from an older version, these steps will help me get PHP 8.4 running smoothly.

How to Install PHP 8.4 on Ubuntu 24.04

How to Install PHP 8.4 on Ubuntu 24.04

To install PHP 8.4 on Ubuntu 24.04, follow these steps:

Update Your System

Ensure all existing packages are up to date:

sudo apt update && sudo apt upgrade -y

 

Add the PHP Repository

Ubuntu's default repositories may not include the latest PHP version. Add the OndÅ™ej Surý PPA, a trusted source for PHP packages:

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

After adding the repository, update the package list:

sudo apt update

 

Install PHP 8.4

Now, install PHP 8.4:

sudo apt install php8.4 -y

To verify the installation:

php -v

 

Install PHP Extensions (Optional)

Depending on your project's requirements, you may need additional PHP extensions. For example:

sudo apt install php8.4-mysql php8.4-xml php8.4-mbstring -y

 

Configure PHP for Web Servers

For Apache users:

Install the PHP module for Apache:

sudo apt install libapache2-mod-php8.4 -y

Enable the module and restart Apache:

sudo a2enmod php8.4
sudo systemctl restart apache2

For Nginx users:

Install PHP-FPM:

sudo apt install php8.4-fpm -y

Ensure PHP-FPM is running:

sudo systemctl status php8.4-fpm

Configure Nginx to use PHP by editing your server block configuration to include:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
}

After updating the configuration, restart Nginx:

sudo systemctl restart nginx

By following these steps, PHP 8.4 should be successfully installed and configured on your Ubuntu 24.04 system.

 


You might also like:

Recommended Post
Featured Post
Optimizing Laravel 11 for Serverless Deployment on AWS Lambda
Optimizing Laravel 11 for Serv...

In this guide, I'll walk you through how to optimize a Laravel 11 application for serverless deployment on AWS Lambd...

Read More

Sep-25-2024

How To Generate PDF and Send Email In Laravel 8
How To Generate PDF and Send E...

In this tutorial we will see how to generate pdf and send email in laravel 8. For generating PDF file we will use l...

Read More

Dec-20-2021

How To Validate Password And Confirm Password Using JQuery
How To Validate Password And C...

In this article, we'll explore a simple way to validate passwords and confirm passwords using jQuery. Password valid...

Read More

Sep-02-2020

How To Get Current User Location In Laravel 9
How To Get Current User Locati...

In this article, we will see how to get the current user location in laravel 9. Many times we are required to...

Read More

Mar-23-2022