After "apt-get dist-upgrade" command was installed PHP 7. How to get back to 5?

2

I use Ubuntu 14.04. And when I ran this apt-get dist-upgrade command here on my machine, it installed PHP 7.

I've already removed PHP 7 like this:

apt-get purge php.*

But when I do this:

apt-get install php

It reinstalls PHP 7 again.

Does anyone know how to solve this?

Update

Only technical information (you do not need to change the answers), is that when I run apt-cache policy php5 , this appears:

php5:
  Instalado: (nenhum)
  Candidato: 7.20151230+deb.sury.org~trusty+1
  Tabela de versão:
     7.20151230+deb.sury.org~trusty+1 0
        500 http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/ trusty/main amd64 Packages
     5.5.9+dfsg-1ubuntu4.14 0
        500 http://br.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
     5.5.9+dfsg-1ubuntu4 0
        500 http://br.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
    
asked by anonymous 04.01.2016 / 16:08

3 answers

2

Before installing, always check for existing packages.

This will return a list of packages containing the word PHP, if any:

>dpkg --get-selections | php

Remove the packages that need to be removed.

  sudo apt-get remove package-name

In bold, type the name of the package exactly as it appears in the search list.

Installing the repository

Add the PHP 5.6 repository or whatever version you prefer. In the example below, it is for version 5.6

>add-apt-repository ppa:ondrej/php5-5.6
>apt-get -y update

Installing PHP

With the repository installed, run the PHP installation:

>apt-get -y install php5

This will do the default installation.

PHP Extensions

After this, you'll obviously want the most used extensions:

>apt-get -y install php5-mcrypt php5-curl php5-gd

The syntax is simple

>apt-get -y install php5-nome_da_extensão

After completing, check out the console

>php -v

Show version

>php -m

Show extensions loaded

    
04.01.2016 / 16:18
2

As it is ubuntu you can download your php and install it, in case it would look like this:

Removing your current php:

apt-get remove --purge yourphppackage

Installing the version you want:

dpkg -i yourphppackage.deb

List of available PHP versions

    
04.01.2016 / 16:17
1

I do not know if it has to do with what @DanielOmine said about the issue of package conflict, but at first I do not think that the apt-get install php5 command works to install PHP 5 (which seems obvious), but to install the latest version of php.

Maybe it is the ppa that should be fixed for php 7 to be installed through the command apt-get install php7 (which did not work here yet).

I solved the problem as follows.

  • I opened the software update configuration

  • I unplugged the options of the ppr of ondrej referring to php7

See:

    
04.01.2016 / 17:13