installphp.info


← Back to home page

Install PHP 7.1 on Ubuntu 20.04

This version of PHP is actively supported.

Good news! PHP 7.1 is being actively supported through 10 Nov 2024. After that point, it's advisable to upgrade to the latest version, since the PHP team will only offer security-related support until 10 Nov 2024, at which point PHP 7.1 will be considered "end-of-life".

Installing PHP 7.1 on Ubuntu 20.04

Prerequisites

  • Ubuntu 20.04 LTS server
  • User account with sudo privileges
  • Terminal access

Installation

  1. Add the PHP repository:

    sudo add-apt-repository ppa:ondrej/php
  2. Update the package list:

    sudo apt update
  3. Install PHP 7.1:

    sudo apt install php7.1
  4. Install common PHP extensions:

    sudo apt install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm

Verification

  1. Check the 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 your web browser:

    http://your_server_ip/info.php