How to install PHP 7.3 on Ubuntu 18.04 (Bionic Beaver)

11173
Share:
how-to-install-php-7-3-on-ubuntu-18-04-bionic-beaver

Update 25-12-2020: PHP 8 installation on Linux Mint 20 Ulyana or Ubuntu 20.04 Focal Fossa is available.

As PHP had officially released PHP version 7.3.9, I decided to install it on one of my development server. It uses Ubuntu 18.04 (Bionic Beaver), so official PHP package provided from their repository is at 7.2.19. Thanks to Ondřej Surý PPA repository that enables us to install the latest versions of PHP. Hence, run the command below to add this PPA repository to your Ubuntu 18.04 system.

Getting Started

As usual, before proceed with actual installation, make sure that your system packages are up-to-date. Run the commands below to perform system package update and upgrade.

$ sudo apt update
$ sudo apt upgrade

Add PPA Repository

As mentioned above, we need to add the ondrej/php which has PHP 7.3 package and other required PHP extensions.

$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php

Notice that after above command entered, message like this will likely shown:

Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or Ctrl-c to cancel adding it.

You can safely press "Enter" and the process will continue. Wait for it to finish end then enter this command:

$ sudo apt update

PHP 7.3 Installation

Right now your Ubuntu 18.04 system is ready for PHP 7.3 installation. Hence, run the command below to install PHP 7.3 on Ubuntu 18.04.

$ sudo apt install php7.3-fpm

After the installation has completed, confirm that PHP 7.3 FPM has installed correctly with this command:

$ php -v
PHP 7.3.9-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Sep  2 2019 12:54:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.9-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

The verification of the same can be done by running the command below:

$ apt-cache policy php7.3-fpm
php7.3-fpm:
  Installed: 7.3.9-1+ubuntu18.04.1+deb.sury.org+1
  Candidate: 7.3.9-1+ubuntu18.04.1+deb.sury.org+1
  Version table:
 *** 7.3.9-1+ubuntu18.04.1+deb.sury.org+1 500
        500 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

Install PHP 7.3 Extensions

If you're web developer like me, usually we need to install various extensions. To find specific extension, you can always search for a specific PHP 7.3 extension by running the command below:

$ apt-cache search php7.3-*

php-amqp - AMQP extension for PHP
php-apcu - APC User Cache for PHP
php-apcu-bc - APCu Backwards Compatibility Module
php-ds - PHP extension providing efficient data structures for PHP 7
php-gearman - PHP wrapper to libgearman
php-geoip - GeoIP module for PHP
php-gmagick - Provides a wrapper to the GraphicsMagick library
php-gnupg - PHP wrapper around the gpgme library
php-http - PECL HTTP module for PHP Extended HTTP Support
php-igbinary - igbinary PHP serializer
php-imagick - Provides a wrapper to the ImageMagick library
php-mailparse - Email message manipulation for PHP
php-memcache - memcache extension module for PHP
php-memcached - memcached extension module for PHP, uses libmemcached
php-mongodb - MongoDB driver for PHP
php-msgpack - PHP extension for interfacing with MessagePack
php-oauth - OAuth 1.0 consumer and provider extension
php-pinba - Pinba module for PHP
php-propro - propro module for PHP
php-radius - radius client library for PHP
php-raphf - raphf module for PHP
php-redis - PHP extension for interfacing with Redis
php-rrd - PHP bindings to rrd tool system
php-smbclient - PHP wrapper for libsmbclient
php-solr - PHP extension for communicating with Apache Solr server
php-ssh2 - Bindings for the libssh2 library
php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP
php-tideways - Tideways PHP Profiler Extension
php-uploadprogress - file upload progress tracking extension for PHP
php-uuid - PHP UUID extension
php-yac - YAC (Yet Another Cache) for PHP
php-yaml - YAML-1.1 parser and emitter for PHP
php-zmq - ZeroMQ messaging bindings for PHP
libapache2-mod-php7.3 - server-side, HTML-embedded scripting language (Apache 2 module)
libphp7.3-embed - HTML-embedded scripting language (Embedded SAPI library)
php-lua - PHP Embedded lua interpreter
php-pcov - Code coverage driver
php-phalcon - full-stack PHP framework delivered as a C-extension
php-xdebug - Xdebug Module for PHP
php7.3 - server-side, HTML-embedded scripting language (metapackage)
php7.3-bcmath - Bcmath module for PHP
php7.3-bz2 - bzip2 module for PHP
php7.3-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.3-cli - command-line interpreter for the PHP scripting language
php7.3-common - documentation, examples and common module for PHP
php7.3-curl - CURL module for PHP
php7.3-dba - DBA module for PHP
php7.3-dev - Files for PHP7.3 module development
php7.3-enchant - Enchant module for PHP
php7.3-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.3-gd - GD module for PHP
php7.3-gmp - GMP module for PHP
php7.3-imap - IMAP module for PHP
php7.3-interbase - Interbase module for PHP
php7.3-intl - Internationalisation module for PHP
php7.3-json - JSON module for PHP
php7.3-ldap - LDAP module for PHP
php7.3-mbstring - MBSTRING module for PHP
php7.3-mysql - MySQL module for PHP
php7.3-odbc - ODBC module for PHP
php7.3-opcache - Zend OpCache module for PHP
php7.3-pgsql - PostgreSQL module for PHP
php7.3-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.3-pspell - pspell module for PHP
php7.3-readline - readline module for PHP
php7.3-recode - recode module for PHP
php7.3-snmp - SNMP module for PHP
php7.3-soap - SOAP module for PHP
php7.3-sqlite3 - SQLite3 module for PHP
php7.3-sybase - Sybase module for PHP
php7.3-tidy - tidy module for PHP
php7.3-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.3-xmlrpc - XMLRPC-EPI module for PHP
php7.3-xsl - XSL module for PHP (dummy)
php7.3-zip - Zip module for PHP

To install specific extension, you can type these command:

$ sudo apt install php7.3-<extension-name>

where <extension-name> is the name of a specific extension. For example:

$ sudo apt install php7.3-bcmath

Final Words

I hope that you now know how to install PHP 7.3 on Ubuntu 18.04 Bionic Beaver. If you run into any issues or have any feedback feel free to drop a comment below.

Tags
Share:

1 comment

Leave a reply

Your email address will not be published. Required fields are marked *