installphp.info


← Back to home page

Install PHP 7.4 on Ubuntu 24.04

Warning! This PHP version is end-of-life!

PHP 7.4 reached end of life on 28 Nov 2022 and is no longer being updated. It's strongly recommended to upgrade to the latest version as soon as possible. You can read the official PHP migration guide here.

Installing PHP 7.4 on Ubuntu 24.04

Prerequisites

  • Ubuntu 24.04 system with sudo privileges
  • Terminal access
  • Internet connection

Installation

  1. Update the package list:
    sudo apt update
  2. Add the PHP repository:
    sudo add-apt-repository ppa:ondrej/php
  3. Install PHP 7.4:
    sudo apt install php7.4
  4. Install common PHP extensions:
    sudo apt install php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath

Verification

  1. Check PHP version:
    php -v
  2. Verify installed modules:
    php -m
  3. Create a PHP info file:
    echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php
  4. Access the PHP info page in a web browser:

    http://your_server_ip/info.php