Upgrade from PHP 7.2 to PHP 7.3. failed on Ubuntu 16.04

Hello!
I’ve tried to make that upgrade, but php -v shows ver. 7.2 and nothing works (get Error in browser when I’m trying to open the site that I host locally). Then I re-enable PHP 7.2. and everything works (except there’s no upgrade!). I followed these instructions:

Login to the server via SSH as root.
Check your current PHP version. 
    # php -v
    PHP 7.2.36
In order to install PHP 7.3, we need to add the repository first:
    # add-apt-repository ppa:ondrej/php
Then run an update:
    # apt-get update
After completing the update, we need to install the PHP 7.3.
    # apt install php7.3 
 Then install the required PHP packages based on your current installation:
    # apt install php7.3-common php7.3-cli php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-readline php7.3-xml php7.3-zip php7.3-fpm php7.3-bcmath php7.3-mbstring
After a successful installation, we can disable the old 7.2 and then enable 7.3:
    # a2dismod php7.2
    # a2enmod php7.3
Then restart Apache:
    # service apache2 restart
The new PHP version should be active now. You can verify it from the command line:
    # php -v
    PHP 7.3.28

It’s all great, except that it doesn’t work in my case… Any ideas?

This is the solution: To manually remove PHP 7.2 
apt-get purge $(dpkg -l | egrep -e php7.2 | awk '{print $2}')
And then do this:
sudo update-alternatives --config php 
And then choose PHP 7.3
1 Like

FYI if you install all PHP versions through that ondrej repository you can switch between them using

sudo update-alternatives --config php

Of course if you only want to run 7.3 then indeed removing 7.2 is easier and will prevent confusion further down the line.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.