Moving an Ubuntu Server from PHP 5 to PHP 7

Moving an Ubuntu Server from PHP 5 to PHP 7

Upgrading PHP is one of the easiest performance wins for an older server. This was the quickest route from PHP 5 to PHP 7 on Ubuntu.

1. Remove the old packages

sudo apt-get -y purge php.*

2. Install PHP 7

sudo apt-get -y update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y update
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv

Before you do this in production

Test your application on the new version first, because removed functions and stricter behaviour can break old code. Today you should target a currently supported release such as PHP 8.2 or newer, using the same repository.

Stuck on something similar? Our PHP development team is happy to take a look.

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.