Upgrade PHP 7.* to 8.*

1 . Uninstall/Remove PHP 7.x and Extensions

sudo apt-get purge php7.*

2. Autoclean and Autoremove

sudo apt-get autoclean

Press Y and ENTER if prompted.

sudo apt-get autoremove

 

3. Install PHP 8

sudo add-apt-repository ppa:ondrej/php

Install PHP 8 (Recomended)

sudo wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Add PHP repository:

 

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
Next, install PHP 8.1 with command line interface (CLI):
sudo apt install -y php8.1-common php8.1-cli

OR

sudo apt-get install php8.*

Restart Apache.

sudo service apache2 restart

4. Install PHP 8 Extensions

sudo apt install php8.*-common php8.*-mysql php8.*-xml php8.*-xmlrpc php8.*-curl php8.*-gd php8.*-imagick php8.*-cli php8.*-dev php8.*-imap php8.*-mbstring php8.*-opcache php8.*-soap php8.*-zip php8.*-intl -y

Restart Apache.

sudo service apache2 restart

5. Check PHP version

php -v

Leave a Reply

Your email address will not be published. Required fields are marked *