1

I have installed php from ondrej. I followed many answers about removing it. However, the apache does not able load php but everytime I try to use php -v from the terminal it returns :

PHP 7.1.4 (cli) (built: May 9 2017 21:55:10) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

3
  • Have you removed the ondrej PPA from your apt lists? Jul 1, 2017 at 4:04
  • Yes using purge
    – SaidbakR
    Jul 1, 2017 at 4:32
  • 1
    Purge only removes the packages and configs, did you actually remove the repos from /etc/apt/? After you remove them there, then you need to update apt-get install update and then reinstall apt-get install php libapache2-mod-php php-mcrypt php-mysql Jul 1, 2017 at 4:34

2 Answers 2

1

The PHP version Apache uses and the PHP version the command php -v uses are two different things.

To use a specific CLI version of PHP, you have to install the php-cli package. After you install it, use update-alternatives to tell the php which version to use.

For example if you want to use php8.1-cli, do this:

sudo apt install php8.1-cli

sudo update-alternatives --set php /usr/bin/php8.1
0

I also had the same issue. You have to sudo apt-get purge php*.

1
  • Can you do this for a specific version of php? I used sudo apt-het purge php7.3 and it said it uninstalled but when I ran php -v it is still showing php7.3 instead of php7.4 Jan 9, 2020 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .