Uninstall php 7 in ubuntu 18.04

This will remove all php7 versions, be it php 7.0 or php 7.1 etc..

sudo apt-get purge php7.*
sudo apt-get autoclean
sudo apt-get autoremove
  • apt/apt-get autoclean → cleans obsolete deb-packages, less than clean
  • apt/apt-get autoremove → removes orphaned packages which are not longer needed from the system, but not purges them, use the --purge option together with the command for that.

**To Install PHP again **

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

if php7.0

sudo apt-get install php7.0

if php7.1

sudo apt-get install php7.1

if php7.2

sudo apt-get install php7.2

To switch that to the newer 7.1,7.2,7.3,7.4 version, first disable older PHP version:

user@test:~# sudo a2dismod php7.0

Then enable PHP 7.2:

user@test:~# sudo a2enmod php7.2
sudo service apache2 restart

Install all the required extension, so it won’t make any error in future.
Replace command based on your version. I used 7.2 as I have installed that version.

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)