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

Asked

Viewed 2,082 times

2

I use Ubuntu 14.04. And when I went to execute this command apt-get dist-upgrade here on my machine, he installed PHP 7.

I’ve already removed PHP 7 like this:

apt-get purge php.*

But when I do so:

apt-get install php

He re-installs PHP 7 again.

Somebody knows how to fix this?

Updating

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

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
  • Tries sudo apt-get install php5 php5-cli and other desired extensions always starting with php5

  • @PHP’s gambiarra starts there. If you specify apt-get install php5, he installs the 7.

  • It looks like some "poverty" in the operating system. Conflict in repositories. , not in php.

  • Truth, maybe I just have to remove the php7 ppa. (I think, from the little list posted above, that there is one for version 7, another for 5.6 and another for 5.5).

  • @Danielomine solved in a weird way, look there.

  • 1

    If you upgrade the version of Ubuntu to 16.04, be sure to see the solution below, which enables you - inclusive - to switch between versions 5.6 and 7.0 of PHP. Worth checking out: http://askubuntu.com/a/762161 Abs, Att. Adrianoleal

Show 1 more comment

3 answers

2

Since it is Ubuntu you can download your php and do the installation of it, in case it would be like this:

Removing your current php:

apt-get remove --purge yourphppackage

Installing the version you want:

dpkg -i yourphppackage.deb

List of available versions of PHP

  • a doubt, it would work in his case? sudo apt-get install php5

  • No, because it will appear in the package list as php7. I just saw it here.

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 packages that need to be removed.

sudo apt-get remove package name

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

Installing the repository

Add the PHP 5.6 repository or other version you prefer. In the example below, it’s for version 5.6

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

Installing PHP

With the repository installed, run PHP installation:

>apt-get -y install php5

This will make the installation standard.

PHP extensions

After this, you will 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 on the console

>php -v

Will show the version

>php -m

Show the loaded extensions

  • Daniel, what’s the point of -y. I’ve seen it many times and I don’t understand it

  • 1

    @Wallacemaxters the y assume that for any prompt option will always be Yes or Yes, ie you do not need to confirm anything, the prompt will always leave Yes automatically :D

  • 1

    Serves to automate confirmations. There are facilities that require dozens of confirmations. If you specify -y, you will be answered "yes" in all questions, automatically. Of course, you should not use it without knowing what you are doing. But in this case it’s just "can you download?" questions, "can you install?". Obviously you will answer "yes" to all these questions, but in this context, blz? rsrs

  • Then it is better not to use - in most cases.

  • Yes. Use only if you already know the questions.

  • @Danielomine, this is not updating. You are informing (without the option -y) that will install the php7. First day of work, that bullshit, huh!

  • even if you specify "install php5"?

  • Even specifying. I will try to remove the ppa and add again :|

Show 4 more comments

1

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

Maybe it’s the ppa that should be fixed so that php 7 is installed through the command apt-get install php7 (that hasn’t worked here yet).

I solved the problem as follows.

  • I opened the software update configuration

  • I unchecked Ondrej ppa options for php7

Behold:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.