Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to run 'composer update' on ssh on hostgator, but php -v to low

Tags:

php

ssh

laravel

Need Help 🛬

Framework - Laravel

Hosting - Hostgator

Problem Statement :- I need to run the 'composer update'. All dependencies required minimun php -v of 5.5.9. I have manualy Upgrade the php version of Project directory to 5.6 from cpanel using 'Php configration' plugin. But when i logged in using ssh, then i got the php -v of 5.4.45. Ofcourse It targeting the deafult php version of the server. Is there any way to update php to 5.6 or above on ssh also. No root user access. No help from support team also. 🎭

like image 634
Ehtasham Malik Avatar asked Sep 22 '16 16:09

Ehtasham Malik


People also ask

What happens if you dont update PHP?

If you use code that is outdated and not supported in the newer version of PHP, then your site will give errors and may stop working altogether. For example, if you haven't updated your CMS to the latest version, or if your website uses custom code, for which an update isn't readily available.

How do I update PHP version in terminal?

Update PHP for WindowsRun php -v from the command line to check your PHP version. If you don't want to update PHP manually, you can use the Chocolatey package manager to install and update PHP version for you. Chocolatey is a package manager for Windows computers, it works like Homebrew for Mac computers.


1 Answers

Using a PRO/Shared Host (tested in Hostgator.com.br) you can do this in SSH (change the usercpanel to your own):

vim /home/usercpanel/.bashrc

In the next page, if it's blank, insert the values:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
 . /etc/bashrc
fi

# User specific aliases and functions

Right after, you will put (you can change the php version: 71, 72, 73 or 74):

alias php='/opt/cpanel/ea-php74/root/usr/bin/php'
export PATH="/opt/cpanel/ea-php74/root/usr/bin:$PATH"

Will be like this

Save the changes and exit.

Now, insert this code to load the new config (change the usercpanel to your own):

source /home/usercpanel/.bashrc

And, insert this code to verify if the alias has been loaded.

alias | egrep 'php'

And then, check if the path is being displayed in the PATH variable:

echo $PATH | egrep '/opt/cpanel/ea-php74/root/usr/bin'

DONE! Tested and working fine for me.

like image 163
Tiago Oliveira Avatar answered Nov 15 '22 13:11

Tiago Oliveira