Vannkorn

Full Stack Web Developer

Close

Upgrade PHP to 7.2 on Vesta CP

When staying on the old environment is better than moving to the new one, updating its stuff to the latest can be daunting and dangerous.

Ads: Register now via this link to receive $100 credit from Vultr

This morning I’m working on upgrading my Vesta CP to use PHP 7.2 as from the newly released WordPress 5.1 suggestion.

1. Add PHP Repository to my Debian

In my case, my Ubuntu operating system does not have PHP Repository yet. I then install it by running the following command:

sudo apt-get install software-properties-common

Then go add the PHP repository by running the following command:

sudo add-apt-repository ppa:ondrej/php

After that I need to make sure this repository is available on my call. I then run the following command:

sudo apt-get update

2. Install PHP 7.2

Now everything needed is available on the server. Installing PHP 7.2 by running:

sudo apt-get install php7.2

3. Tell Apache to use PHP 7.2

The Apache server is still using the previous version of PHP unless I disable the previous one and enable the 7.2 version.

To disable the previous PHP version, in my case, PHP 5, run:

sudo a2dismod php5 

To enable the newest version of the installed PHP, run:

sudo a2enmod php7.2

To get the change affected, restart the apache server:

sudo service apache2 restart

4. Installing Extensions

There are extensions that might be needed to replace the deprecated ones or required by PHP 7.2. The following extensions are some that may fix your need:

sudo apt-get install php7.2-common libapache2-mod-php2.1 php2.1-cgi php7.2-cli php7.2-phpdbg php7.2-fpm libphp7.2-embed php7.2-dev php7.2-curl php7.2-gd php7.2-imap php7.2-interbase php7.2-intl php7.2-ldap php7.2-mcrypt php7.2-readline php7.2-odbc php7.2-pgsql php7.2-pspell php7.2-recode php7.2-tidy php7.2-xmlrpc php7.2-json php-all-dev php7.2-sybase php7.2-sqlite3 php7.2-mysql php7.2-opcache php7.2-bz2 libapache2-mod-php7.2 php7.2-mbstring php7.2-pdo php7.2-dom phpize7.2

To get these extensions up and running, restart the apache:

sudo service apache2 restart

5. Fixing Errors After Upgrading to 7.2

In my case, I got an error saying “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

As per it says, the MySQL extension is missing. To fix, go install it:

sudo apt-get install php-mysql

Then restart Apache:

sudo service apache2 restart

I also met the CURL error too when hitting save a post on WordPress. To fix, simply install the CURL extension and restart apache

Install CURL extension:

sudo apt-get install php7.2-curl

Restart Apache:

sudo service apache2 restart

Install Image Magic

sudo apt-get install php-imagick

Restart Apache:

sudo service apache2 restart

6. Known unsupported WordPress plugins

There are a few PHP warning errors of some WordPress plugins after upgrading PHP to version 7.2.

In this time of writing, those plugins are:

  1. All Push Notifications
  2. Facebook Instant Articles
  3. JetPack

Read more tips on migrating from PHP 5 to PHP 7 part 1 and Part 2

Leave a Reply

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