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.

3
  • 1
    You need to install the newest version. Do you have access to the server? Commented Jun 13, 2015 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. Commented Jun 13, 2015 at 14:27
  • If the above didn't work try this solution from another answer stackoverflow.com/questions/46986139/… Commented Jun 8, 2018 at 14:45

3 Answers 3

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>'
Sign up to request clarification or add additional context in comments.

4 Comments

I don't have access to the folder where php is being picked from =/
Then your only option is to set the PATH environment variable to point to where the correct PHP binary lives. See: stackoverflow.com/questions/14637979/…
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?
Can you post the output of which php
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.

Comments

0

1) phpbrew

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.