PHP 7.0 on Ubuntu 19.04

Linode Staff

How do I install PHP 7.0 on Ubuntu 19.04?

1 Reply

Ubuntu 19.04 ships with PHP 7.2, and can be installed from the main repositories.

sudo apt install php7.2 -y

Although I recommend version 7.2 for security and performance, if you have an application that requires 7.0, you can install it by adding a Personal Package Archive (PPA) repository.

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.0 -y

If you already have version 7.2 installed, you’ll need to update the symlink for the PHP binary to make 7.0 the default. You can check the current version you’re running with php -v.

Check version:

php -v | grep "PHP 7"    
. . .
PHP 7.2.19-0ubuntu0.19.04.2 (cli) (built: Aug 13 2019 11:45:23) ( NTS )

Select the alternative:

sudo update-alternatives --config php
. . .
There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php7.2   72        auto mode
  1            /usr/bin/php7.0   70        manual mode
  2            /usr/bin/php7.2   72        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/php7.0 to provide /usr/bin/php (php) in manual mode

Verify:

php -v | grep "PHP 7"
. . .
PHP 7.0.33-10+ubuntu19.04.1+deb.sury.org+1 (cli) (built: Aug  7 2019 09:52:17) ( NTS )

You might also find this post helpful for configuring PHP 7.0 with Apache.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct