41

I have upgraded PHP old version to latest php7 but unable to start its services.

systemctl restart apache2.service

Job for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xe" for details.

Status Detail:

systemctl status apache2.service


● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Active: failed (Result: exit-code) since Mon 2016-01-04 13:58:17 IST; 5s ago
 Docs: man:systemd-sysv-generator(8)
 Process: 16666 ExecStart=/etc/init.d/apache2 start (code=exited,       status=1/FAILURE)

Jan 04 13:58:17 GCT022 apache2[16666]: *
Jan 04 13:58:17 GCT022 apache2[16666]: * The apache2 configtest failed.
Jan 04 13:58:17 GCT022 apache2[16666]: Output of config test was:
Jan 04 13:58:17 GCT022 apache2[16666]: apache2: Syntax error on line 140 of /etc/apache2...
Jan 04 13:58:17 GCT022 apache2[16666]: Action 'configtest' failed.
Jan 04 13:58:17 GCT022 apache2[16666]: The Apache error log may have more information.
Jan 04 13:58:17 GCT022 systemd[1]: apache2.service: control process exited, code=exit...s=1
Jan 04 13:58:17 GCT022 systemd[1]: Failed to start LSB: Apache2 web server.
Jan 04 13:58:17 GCT022 systemd[1]: Unit apache2.service entered failed state.
Jan 04 13:58:17 GCT022 systemd[1]: apache2.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
root@client022:/home/user22$ ^C

Now I want to revert back or remove php7 that i can do the user machine active with the old version.

Ramesh Chand
  • 7,274
  • 4
  • 33
  • 37

7 Answers7

111

To remove php7.0 use

sudo apt-get purge php7.0-common
Byte Commander
  • 107,489
kbarhoum
  • 1,111
37

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

sudo apt-get purge php7.*
12

As I have answered your question Unable to locate package php7.0 and you have accepted my answer and because you explicitly ask for a removal of the package:

sudo apt-get install ppa-purge
sudo ppa-purge ppa:ondrej/php-7.0
A.B.
  • 90,397
5

to remove php7.x simpely use

sudo apt-get purge `dpkg -l | grep php7.2| awk '{print $2}' |tr "\n" " "`
5

If you run Abhishek's it will remove other packages. On mine it was going to remove these too

The following packages will be REMOVED

libapache2-mod-php5.5* libapache2-mod-php5.6* php-common* php-gettext* php-igbinary* php-memcached* php-msgpack* php-pear* php-xdebug* php5-cli*
php5-common* php5-dev* php5-json* php5-memcache* php5-memcached*
php5-readline* php5-redis* php5-xdebug* php5.5-cli* php5.5-common*
php5.5-curl* php5.5-json* php5.5-mysql* php5.5-opcache* php5.5-readline* php5.5-xml* php5.6* php5.6-cli* php5.6-common* php5.6-curl* php5.6-fpm* php5.6-json* php5.6-mbstring* php5.6-mysql* php5.6-opcache* php5.6-readline* php5.6-xml* pkg-php-tools*

So you're better off with

sudo apt-get purge php7.*
3

The way to remove PHP and dependencies is:

apt-get autoremove php7.0
Zanna
  • 70,465
ANL
  • 31
  • This is the same as most of the other answers. – fosslinux Apr 17 '18 at 04:26
  • 1
    I don't think any of the other answers suggest precisely this... – Zanna Apr 17 '18 at 06:14
  • 1
    @Zanna You are right. Moreover, this seems to work on my Ubuntu 16.04 but giving a package name to apt-get autoremove is not documented in the man page. – Melebius Apr 18 '18 at 07:29
  • 1
    @Melebius yes it works for me on 17.10 too - autoremove in place of remove causes the orphaned dependencies to be removed at the same time, which saves running an additional command. I don't know why it is not documented as it's very useful! – Zanna Apr 18 '18 at 07:38
2

After doing a:

sudo apt-get purge php7.*

to remove all versions of php7, you still need to run some extra steps to completely and utterly remove php7:

sudo apt-get autoremove --purge

Then do a:

whereis php

and then remove all directories in the output of the last command, E.G.:

sudo rm -rf /etc/php
Fabby
  • 34,259
Katie
  • 121