Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

inayan's avatar

How to fix the issue of machine showing different version of php in php-cli and phpinfo ?

Recently I installed Xampp on my linuxmint pc and it came with php version 8.1.6 when I checked in phpmyinfo . But when I tried to check it in terminal it throws en error as "php" command not found and advised to install php-cli . So I installed the php-cli with sudo apt install php-cli command . Now after checking with php --version command it shows php version 7.4.3 (cli) and not 8.1.6 . So is there a way to configure the command line so that it shows the correct php version installed on my pc ?

0 likes
11 replies
Sinnbeck's avatar

Try giving it the version in the install command

sudo apt install php8.1-cli 
inayan's avatar

@Sinnbeck Got his error -

E: Unable to locate package php8.1-cli

E: Couldn't find any package by glob 'php8.1-cli'

Sinnbeck's avatar

@inayan Perhaps you are missing this (it contains the newest php version.. ubuntu/linux mint does not)

sudo add-apt-repository ppa:ondrej/php

And awesome to see someone else running linux mint :)

inayan's avatar

@Sinnbeck okay but what about the php8.1 which is installed through xampp in my pc ? If I add this repository what would happen to my already installed php ? will there be any conflict ? Using linux mint as main OS since five years now , fell in love the first time i used it .

Sinnbeck's avatar

@inayan I have never used xampp so I honestly don't know. I don't know how it installs it and from where. I use docker myself.

You can also just see if its already installed, and pick it for cli

sudo update-alternatives --config php

Just switched from ubuntu to linux mint last year, and it is so nice! :)

inayan's avatar

@Sinnbeck the commmand gives this output -

There is only one alternative in link group php (providing /usr/bin/php): /usr/bin/php7.4
Nothing to configure. 

I actually have explained it in detail in stack overflow didn't got any answer . please see look at it once - https://stackoverflow.com/q/73155535/19465215

( linux mint is awesome , people who are involved in it are awesome , I hope it never dies )

Sinnbeck's avatar

@inayan Personally I would probably just install the repo so I can install php8.1 on my system. And if xampp gives you problems, then perhaps decide if its the best pick for the job. You can just let php install apache2 on your system and set that up (its just setting up one file).

Or you can even go the docker route that I have gone. I can set up a new project with a specific php version, and mysql version in a minute or two. I use something called Lando, to ease the setup process :) https://sinnbeck.dev/posts/using-lando-to-run-laravel-in-docker

inayan's avatar

@Sinnbeck Actually xampp works fine , I was just about to install composer and before doing it I wanted to check my php version and all these happenned . I am pretty sure if I install composer and laravel now it will just work as normal like it did earlier . But I just want to fix this for my own peace of mind and want to know why this happened . Anyway Thanks for your advice , I will see if I can get used to docker .

Sinnbeck's avatar

@inayan My guess is that xampp manages its own php versions separately from your local installs, so adding the PPA and installing php 8.1 manually wouldnt change anything for xampp (I would assume) :)

1 like
inayan's avatar

@Sinnbeck yes thats most likely the case . Should I add the ppa or let it stay as it is , what would be your advice .

Sinnbeck's avatar

@inayan I would add the ppa, and install php8.1

sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.1-cli
sudo update-alternatives --config php
1 like

Please or to participate in this conversation.