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’

Leave a Comment