Handysolver
Home Case Studies Technology

Update PHP Version on Ubuntu and then update in Client and Apache

Author Image

Rahul Matharu

10 Jul, 2020 · 1 min read
Article Thumbnail

Source

# Add the repository 'ppa:ondrej/php'
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade # *Note: Had to also run at 
end however this updates all Ubuntu packages.

# Install PHP 7.3
sudo apt install -y php7.3 php7.3-cli libapache2-mod-php7.3
sudo apt install -y php-imagick php-gettext php-memcache php-apcu php-pear php-xml php-xmlrpc
sudo apt install -y php-memcached php-mysql php-intl php-mbstring php-curl php-gd php-imagick
sudo apt install -y php7.3-common php7.3-mysql php7.3-cgi
sudo apt install -y php7.3-curl php7.3-zip php7.3-mbstring php7.3-xmlrpc php7.3-gd php7.3-xml php7.3-xsl
sudo apt install -y php7.3-dev php7.3-bz2 php7.3-intl php7.3-json php7.3-opcache php7.3-readline
sudo apt install -y php7.3-imap php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-bcmath #php7.3-mcrypt

# Update/Switching the Apache's PHP version
sudo a2dismod php7.0
sudo a2enmod php7.3
sudo systemctl restart apache2.service

# Update/Switching the CLI PHP version
sudo update-alternatives --set php /usr/bin/php7.3


Possible Errors:

W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C

The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease' is not signed.

N: Updating from such a repository can't be done securely, and is therefore disabled by default.

Fix:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
apt update

Source



Author Image

Rahul Matharu