Make sure the repository link is added to the source list before trying to install.
sudo apt -y install lsb-release apt-transport-https ca-certificates sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
Now install the PHP version you want to install.
sudo apt -y install php7.3
Install the common extensions
sudo apt install php7.3-cli php7.3-fpm php7.3-json php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json
For apache install the module.
sudo apt install libapache2-mod-php7.3
After module of PHP is installed disable the existing version in apache and enable the targeted version.
sudo a2dismod php5.6 php7.1 php7.0 sudo a2enmod php7.2
To set default CLI php version.
sudo update-alternatives --set php /usr/bin/php7.2
Leave a comment