0

I'm trying to install the composer on my website, but the server is running PHP 5.2, and the more I change my version of PHP by cpanel, it continues running PHP 5.2 on the command line.

When I run the php -v he passes me that the version of PHP is 5.2

Is there any way I can change the version of PHP in the command line? Or something like this.

Deharlan
  • 32
  • 2
  • 11
  • 1
    You need to *install* the newest version. Do you have access to the server? – Sverri M. Olsen Jun 13 '15 at 14:25
  • I bought a host from br.bluehost, i tried to talk with support but they are so slowly to answer, i think i have access to the server, i don't know how much. – Deharlan Jun 13 '15 at 14:27
  • If the above didn't work try this solution from another answer https://stackoverflow.com/questions/46986139/how-to-change-php-version-used-by-composer – simon simon Jun 08 '18 at 14:45

3 Answers3

1

Without knowing the setup it is hard to advise you but this may work:

Usually when multiple PHP versions are present, a symlink is used to point /usr/bin/php to the version of PHP binary that should be active.

Firstly find out where the php executable is being picked from. This you can do by typing which php. This will tell you where php is being picked from. Now go to that folder and do ls -l and check if the php executable is a symlink. If it is a symlink you can delete the symlink and create a new one in its place that points to the correct PHP version binary.

ln -s '<path to php binary you want>' '<path returned by which php>'
Ali
  • 1,462
  • 2
  • 17
  • 32
  • I don't have access to the folder where php is being picked from =/ – Deharlan Jun 13 '15 at 14:37
  • Then your only option is to set the PATH environment variable to point to where the correct PHP binary lives. See: http://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux – Ali Jun 13 '15 at 14:40
  • I just got access the folder, and tried to do what passed me, and I made the command: `ln -s '/usr/local/altphp55/bin/php' '/usr/local/bin/php'` but did not change the version of my php. did I do something wrong? – Deharlan Jun 13 '15 at 14:56
  • Can you post the output of `which php` – Ali Jun 14 '15 at 15:26
1

I had the same issue php 7 in cli, but the browser php is 5.6

I used

$ php5.6 <command>

This worked for me.

TimVS
  • 19
  • 3
0

1) phpbrew

2) echo "alias php='/usr/bin/< youre php version php7.1>'" >> ~/.bashrc && source ~/.bashrc