Sometimes on the hosting, you need to work with some specific versions of programming languages and path to it can be also specific.
The same situation was in my case: I need to use php 8.2 but default on the server php set up to 8.1 version and the path to the correct version is like so: /opt/alt/php82/usr/bin/php
Let's fix this issue through adding alias to our configuration.
nano ~/.bashrc
Later we need to modify the file like so:
--------------------------------------
--------------------------------------
--------------------------------------
--------------------------------------
# User specific aliases and functions
alias php='/opt/alt/php81/usr/bin/php'
alias php82='/opt/alt/php82/usr/bin/php'
alias composer82='/opt/alt/php82/usr/bin/php /usr/local/bin/composer'
--------------------------------------
--------------------------------------
--------------------------------------
## another aliases
Don't forget to save the file. In my case through nano it was easy:
^X [enter]
For those who prefer VIM the hints I will place in separate post. 😇
Don't forget to load your updated file
source ~/.bashrc
After that, when you will execute the command you will recieve the data about new version of php.
php82 -v
PHP 8.2.15 (cli) (built: Jan 17 2024 16:34:33) (NTS)
Copyright (c) The PHP Grou
That's all. Happy coding 👏
Thumbnail by: https://unsplash.com/@basvde