0

I have installed php and in cmd on doing

sudo /usr/local/php7/bin/php -v

it shows the php version but on doing

php -v

its not showing getting us command not my phpinfo() also workd

how can I point to get php version on simply doing php -v

I am using centos7

2
  • 1
    Is /usr/local/bin in your $PATH in .bashrc or .zshrc (if you use zsh)? It looks like just a problem of PATH configuration. You can check it with env $PATH Commented Feb 10, 2019 at 11:41
  • Is there a way to point with the same path. Commented Feb 10, 2019 at 13:02

2 Answers 2

1

In your .bashrc modify your PATH:

PATH=$PATH:/usr/local/bin 

or if you have to override the default version of PHP on Centos (this gives "priority" to PHP and other executables in /usr/local/bin)

PATH=/usr/local/bin:$PATH 

save and exit, then:

source ~/.bashrc 

It should work and php -v doesn't require you to specify the full path

Further reading:

https://www.tecmint.com/set-path-variable-linux-permanently/

https://help.dreamhost.com/hc/en-us/articles/214202148-How-do-I-change-the-PHP-version-my-shell-uses-

I assume you are beginning your geeky adventures with Linux, if the answer is yes, take also a look at:

https://vegibit.com/vi-editor-tutorial-for-beginners/

https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/

Hope this solution can help you ;-)

1
  • Thank You, It also fixed my composer issue. Commented Feb 18, 2019 at 16:21
0

With my local ubuntu 18.04 I changed from PHP 7.1 to 7.2

 vi ~/.bashrc echo "PATH=/usr/bin/php7.2:\$PATH" >> ~/.bashrc echo "alias php='/usr/bin/php7.2'" >> ~/.bashrc source ~/.bashrc sudo a2dismod php7.1 sudo a2enmod php7.2 sudo update-alternatives --set php /usr/bin/php7.2 sudo service apache2 restart 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.