I am using NextCloud in my server and NextCloud informs me that:
You are currently running PHP
7.0.32-0ubuntu0.16.04.1
. Upgrade your
PHP version to take advantage of performance and security updates
provided by the PHP Group as soon as your distribution supports it.
So, I tried to upgrade me OS (Ubuntu 16.04), by executing:
apt-get update
apt-get dist-update
Then I restarted the server and I re-executed the above commands. After all these, when I connect from terminal I am getting:
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-83-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 packages can be updated.
0 updates are security updates.
and my PHP version is still PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )
.
This means that PHP 7.0.32 is the latest possible version that I can install in ubuntu 16.04;
Best Answer
The default PHP version for Ubuntu 16.04 is 7.0. If you want to install a new version of PHP on 16.04 you need to use an additional PPA (as it is shown below) or you must compile it on your own.
My server with Ubuntu 16.04 currently uses PHP 7.2 and there are several operational instances of WordPress and MediaWiki. The web server is Apache 2.4. The commands that I've used to migrate from PHP 7.0 to 7.2 are:
In the repository
ppa:ondrej/php
PHP 7.3 is also available, I think to migrate soon to this latest version.If there is a problem with the public key of the repository, you can use this solution.
Here are the additional tweaks of my
/etc/php/7.2/apache2/php.ini
that are made according to few WordPress and MediaWiki manuals:Update 04.2019
I've used the above set of commands to install PHP 7.3 on Ubuntu 16.04 and everything went completely fine. Just replace 7.2 with 7.3 within these commands - the entire process took about 7 minutes.
Update 02.2020
I've migrated to PHP 7.4 and everything went well, during that process I've used the following steps (note, at this date NextCloud doesn't support php7.4 yet):
Update 06.2020
Now I'm using Ubuntu 20.04 Server, it comes by default with php7.4, but I need php7.3. The method above, by using
ppa:ondrej/php
, solves my issue.