Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I'm trying to figure out how to change which version of PHP the php alias uses...

I want it to use: /opt/plesk/php/5.6/bin/php

But it currently uses: /usr/bin/php (I think)

How can I ensure that when typing php through SSH, that it's using the updated plesk version?

share|improve this question

1 Answer 1

Create an alias. First determine the default shell that is running when you login via ssh.

echo $SHELL
/bin/bash

Assume it's bash.

In your user home directory, have the file: .bashrc

add:

alias pphp="/opt/plesk/php/5.6/bin/php"

save. Log out. Log back in. Or just reload .bashrc via source:

source .bashrc

Then to launch plesk php, just type pphp as the command rather than php alone.

Test to make sure this meets your needs.

If your default shell is not bash, just look up how to create an alias for that shell.

share|improve this answer
    
This is great, but I need the alias to be php because some composer scripts that are run automatically during updates to Laravel assume the command... is that a problem? – dcolumbus Nov 10 at 5:47
    
That's different. php is not an alias, it's the actual file name of the executable. Located by: which php, usually something like: /usr/bin/php. which gives the system path, assuming the path of the program is in $PATH, it just looks through the $PATH data until it finds the application name, php in this case. I can't comment on things like plesk plus something else because it's not something I would ever use, too complicated, too much room for error. If some scripts run automatically, it's harder to set different paths since they are running as a different user than you, like www-data etc. – Lizardx Nov 10 at 6:05
    
Plesk isn't running separate scripts... I'm installing Laravel, which automatically executes an "artisan" command that utilizes php. – dcolumbus Nov 10 at 16:56
    
Is there no way to switch out the version of php that is located at /usr/bin ? – dcolumbus Nov 10 at 17:09
    
If you have root on the system, you can install whatever you like. If you don't, you can't. Current php is 5.6, well, actually 7 now, but you'd be installing 5.6. I avoid commenting on things like plesk/cpanel because they are such horrible internal messes that it grows very hard to predict what a system that has them installed will do when you try to run the server as if they were not there. I realized we hadn't even checked your local real system php version: php --version – Lizardx Nov 10 at 20:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.