Uninstalling PHP in Ubuntu is quite easy and straightforward. Let us consider we have PHP version 7.0 and we want to remove it from Ubuntu.
The following command will remove PHP from Ubuntu:
sudo apt-get purge php7.0 // php7.* if we want to remove PHP version starts with 7 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 that are no longer needed from the system, but not purges them, use the –purge option together with the command for that.
To install PHP we can follow this article:
Install PHP on Ubuntu