I'm trying to upgrade from PHP 5.6.35 to PHP 7.2, I did run the following command:
sudo apt install php7.2 php7.2-common php7.2-cli php7.2-cgi php7.2-fpm
All went fine, but when I tried to install laravel, it is saying my php version is 5.6 and I need to upgrade it. So I checked php path using which
which php:
/usr/local/bin/php
which php7.2:
/usr/bin/php7.2
Seems my php 7.2 is installed under /usr/bin
and my old php is under /usr/local/bin
and linux keeps reading old php version. How can I fix it so when I type php -v
I will get 7.2 version?
I'm begginer on linux and I was searching on google but could find solution for my problem. Thank you for your help.
/usr/local/bin/php
is just a symlink, you can create a symlink to use php7.2 as a default for your shell
ln -s `which php7.2` /usr/local/bin/php
However, I don't think this is your real question though. The thing is your webserver (I guess it's Apache) use php5 instead of php7.2. If so, you need to deal with apache modules. There is nothing to do with /usr/local/bin/php
. You have to disable php5 module and enable php7.2 one.
sudo a2dismod php5
sudo a2enmod php7.2
Then restart apache
sudo service apache2 restart