installphp.info


← Back to home page

Install PHP 8.0 on Ubuntu 22.04

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

PHP 8.0 reached end of life on 26 Nov 2023 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 8.0 on Ubuntu 22.04

Prerequisites

  • Ubuntu 22.04 LTS installed
  • Root or sudo access to the system
  • 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 8.0 and common extensions:

    sudo apt install php8.0 php8.0-common php8.0-cli php8.0-fpm
  4. Install additional PHP extensions as needed:

    sudo apt install php8.0-mysql php8.0-curl php8.0-gd php8.0-mbstring php8.0-xml

Verification

  1. Check the installed PHP version:

    php -v

    You should see output indicating PHP 8.0.x is installed.

  2. Verify installed PHP modules:

    php -m

    This will list all installed PHP modules.

  3. Create a PHP info file:

    echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php
  4. Access the PHP info file in your web browser:

    Visit http://your_server_ip/info.php to see detailed PHP configuration information.