Uninstall php 7 in ubuntu 18 04

0 votes

I have a server with a PHP 5.6-based application running on it. However, I changed the server's operating system from Ubuntu 14.04 to 18.04 and, in the process, upgraded PHP to 7.2. I'm currently attempting to uninstall it, but I'm having trouble. 

I have run the command:

sudo apt-get remove php

and

sudo apt-get remove --purge php

Although it claims that PHP is not installed, when I execute PHP —version, I still see PHP version 7.

PHP 7.2.19-0ubuntu0.18.04.2 (cli) (built: Aug 12 2019 19:34:28) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.19-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies

Can someone please help me with this?

Aug 2, 2022 in PHP by Kithuzzz
• 38,000 points
4,384 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

This will uninstall all versions of PHP 7, including 7.0, 7.1, and other versions.

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 no longer needed from the system, but do not purges them, use the --purge option together with the command for that.

Again install PHP using:

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

php7.0

sudo apt-get install php7.0

php7.1

sudo apt-get install php7.1

php7.2

sudo apt-get install php7.2

Then enable PHP 7.2:

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

Install all necessary extensions to ensure future error-free operation. Change the command to match your version. I used 7.2 because I had it installed.

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

I hope this helps you.

answered Aug 3, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In PHP

0 votes
1 answer

How can I enable the MySQLi extension in PHP 7?

Hello @kartik, The problem is that the package ...READ MORE

answered Oct 30, 2020 in PHP by Niroj
• 82,840 points
4,079 views
0 votes
0 answers

Switch php versions on commandline ubuntu 16.04

On my Ubuntu 16.04, I've installed PHP ...READ MORE

Jul 30, 2022 in PHP by Kithuzzz
• 38,000 points
799 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,415 views
0 votes
1 answer

What is type casting and type juggling in php?

Hey, The way by which PHP can assign ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
7,312 views
0 votes
2 answers

How can we create a session in PHP?

Hello, niroj. Here is my idea session_start(); $_SESSION['USERNAME'] ...READ MORE

answered Dec 7, 2020 in PHP by Famous
• 140 points
1,437 views
0 votes
1 answer

What is the use of $_REQUEST variable in php?

Hii @kartik, The $_REQUEST variable is used to read the ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,636 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
1,431 views
0 votes
1 answer

Installing PHP on Ubuntu

Hi Vijay, althought its not necessary to ...READ MORE

answered Mar 1, 2019 in Others by Abha
• 28,140 points
1,332 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,538 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP