How to Install PHP 8.4 on Ubuntu 24.04 for Apache

How to Install PHP 8.4 on Ubuntu 24.04 for Apache

admin By  October 7, 2025 0 7
php8.4

PHP 8.4 is the latest version of the popular open-source scripting language used primarily for web development. It introduces new performance improvements, enhanced type safety, and better syntax features to make code more efficient and developer-friendly.
You can use PHP 8.4 to build dynamic websites, APIs, and web applications. After installing it on your server (for example, on Ubuntu using apt install php8.4), you can create .php files and run them through a web server like Apache or Nginx. Simply write PHP code inside <?php ... ?> tags, and the server will process the code to generate dynamic HTML output for your website.

Here’s a simple, step-by-step guide to install PHP 8.4 on Ubuntu 24.04 👇

Step 1: Update your system

# sudo apt update && sudo apt upgrade -y

Step 2: Install dependencies

# sudo apt install ca-certificates apt-transport-https software-properties-common lsb-release -y

Step 3: Add the PHP repository

PHP 8.4 packages are available from Ondřej Surý’s PPA, which is the most reliable PHP repo for Ubuntu.

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

Step 4: Install PHP 8.4

Now you can install Latest php8.4 on ubuntu 24.04.
# sudo apt install php8.4 -y

Step 5: Install common PHP 8.4 extensions

You can install typical extensions like this:
# sudo apt install php8.4-cli php8.4-common php8.4-mysql php8.4-xml php8.4-gd php8.4-curl php8.4-mbstring php8.4-zip php8.4-bcmath php8.4-intl -y

Step 6: Verify PHP version

# php -v

Step 7 (optional): Configure Apache

Now you can install Apache web server so you can verify php8.4 is installed and configure correctly.

# sudo apt install libapache2-mod-php8.4 -y
# sudo a2enmod rewrite
# sudo systemctl restart apache2

Step 8 (optional): Check PHP info in browser

Create a test file using below command:

# echo “<?php phpinfo(); ?>” | sudo tee /var/www/html/info.php

Then Visit:
http://your_server_ip/info.php

Now we have installed php8.4 successfully with Apache
Thanks for Watching…