There was a problem loading the comments.

How do I specify the version of PHP to use via SSH/command line?

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
At Eco Web Hosting we run multiple versions of PHP side-by-side on the servers, you can update this using the Switch PHP Version option in your hosting control panel for files being called through a browser but this won't take effect over command line meaning you will need a slightly different approach. In this instance, there are two main options depending on how often you are wanting to run things via SSH.

Firstly, if this is a one-off command, or something you are not going to use on a regular basis, you can specify the binary to use each time. Rather than using...

php command


...for example, you will need to specify the version to use by tweaking that command to read...

/user/bin/php74 command


...which will then run this using PHP 7.4. A full list of binaries will be presented to you when logging into the package over SSH each time if you need this information.

Secondly, you can add an alias to the .bash_profile that will set the version to use, by doing this you are effectively setting a shortcut for the php command and specifying the version to use by adding...

alias php="/usr/bin/php74"


...which will set the version to PHP 7.4. If you then use the command from the original example you won't need to specify the binary but bear in mind this will then use this version each time you run a command using php so be sure it's what you're wanting to do before adding. The .bash_profile file can be found in the root of your webspace when first SSH'ing into the package and can be edited from there.

Share via
Did you find this article useful?  

Related Articles

© Eco Web Hosting