3

Problem: When I ssh to my web server and run anything with "php", it runs an old php 5.2 for some reason. The link /usr/bin/php points to the wrong version. I cannot change this symlink.

What I tried: From folder ~/test I'd like to install something, but it requires php 5.6. So I created a symlink in folder ~/tes which points to php5.6:

ln -s /usr/bin/php56 php

To make sure the system checks the current directory for php, I've changed PATH variable and added current directory first:

PATH=/home/test:$PATH

No luck though.

4
  • Are you running it from a web page? If so, what is your web server? Commented Aug 17, 2016 at 19:25
  • @JuliePelletier, from a terminal, ssh
    – vega
    Commented Aug 17, 2016 at 19:53
  • @drewbenn it just calls php
    – vega
    Commented Aug 17, 2016 at 19:54
  • export PATH=/home/test:$PATH
    – chugadie
    Commented Aug 18, 2016 at 12:56

1 Answer 1

2

You have provided the wrong directory in PATH declaration.

You have set the link in ~/test/ directory but in PATH declaration you have used /home/test.

Assuming you username is foobar, you need:

export PATH=/home/foobar/test:"$PATH"

Or just:

export PATH=~/test:"$PATH"

Or:

export PATH="$HOME"/test:"$PATH"

export is to make the changed PATH available to all child processes.

7
  • I've properly exported the path as suggested, which is confirmed when I echo $PATH. But when I type which php it points to the symlink in /usr/bin/php and so php -v still prints php 5.2. Maybe there's some environment variable I'm not aware of?
    – vega
    Commented Aug 17, 2016 at 20:00
  • @vega Thats not possible, if you made the symlink properly and put the directory in the PATH at first it will be treated first. On a different note, you probably have 'alternatives` installed but that is a different matter. What happens when you use the link directly by full path?
    – heemayl
    Commented Aug 17, 2016 at 20:07
  • Interesting, when I try full path ~/test/php -v I get Permission denied, which explains why it defaults to the other symlink. Why denied? I just created it.
    – vega
    Commented Aug 17, 2016 at 20:17
  • @vega check the permission of /usr/bin/php56
    – heemayl
    Commented Aug 17, 2016 at 20:18
  • permission is -rwxr-xr-x. But if I run /usr/bin/php56 -v, it works, no permission warning. So why would it not work through the symlink?
    – vega
    Commented Aug 17, 2016 at 20:30

You must log in to answer this question.

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