Quick notes: Upgrade PHP 7.0 (EOL) to PHP 7.3 on VestaCP running on Ubuntu 16.04

Do this.

# Take a record (optional)
dpkg --get-selections | grep -i php > prephp.txt
php -m >> prephp.txt 

# Do the upgrade
apt install software-properties-common python-software-properties
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/apache2
apt update
apt install libapache2-mod-php7.3 php7.3 php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-gd php7.3-imap php7.3-intl php7.3-json php7.3-ldap php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-pspell php7.3-readline php7.3-soap php7.3-xml 
php --version

# Fix apache
a2dismod php7.0 
a2enmod php7.3
systemctl restart apache2

# What changed (optional)
dpkg --get-selections | grep -i php > postphp.txt
php -m >> postphp.txt 
diff prephp.txt postphp.txt 

That's all … just seem to have been doing this a lot recently, so I thought I'd write it down somewhere. Odd that PHP 7.0 is end of life, yet its the only PHP officially running on Ubuntu 16.

This proved to be a useful command for generating lists of packages to install.


dpkg --get-selections | grep php | grep -v deinstall | grep install | awk '{print $1}' | tr '\n' ' '

And I guess this might have been better:

dpkg --get-selections | grep php | grep -v deinstall | grep php7.0 | awk '{print $1}' | tr '\n' ' ' | sed 's/php7.0/php7.3/g'

And for Ubuntu 18.04 …

Ubuntu 18.04 comes with php7.2 anyway, so the process is a bit easier, and the ondrej repository actually does much of the work for you.

# ondrej repo will upgrade 7.2 and install much of 7.3 for you
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php # and hit ENTER
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php #and hit ENTER
apt upgrade

#Fix apache
a2dismod php7.2
a2enmod php7.3
systemctl restart apache2

# What PHP 7.2 extensions do we have installed? Install the equivalent PHP 7.3 ones. 
dpkg --get-selections | grep php | grep -v deinstall | grep php7.2 | awk '{print $1}' | tr '\n' ' ' | sed 's/php7.2/php7.3/g'
apt install {copy and paste list from above}

1 thought on “Quick notes: Upgrade PHP 7.0 (EOL) to PHP 7.3 on VestaCP running on Ubuntu 16.04”

  1. apt install $( dpkg –get-selections | grep php | grep -v deinstall | grep php8.2 | awk '{print $1}' | tr '\n' ' ' | sed 's/php8.2/php8.3/g' )

Leave a Comment