How can I change php-cli version on Ubuntu 14.04?

后端 未结 7 904
面向向阳花
面向向阳花 2020-12-04 09:41

I am new to using Linux and I broke some php settings while tampering.

If I execute a php script containing: phpinfo(); it shows the php versions as 5.

7条回答
  •  一生所求
    2020-12-04 10:11

    Plesk

    Just to say, if your server is managed using Plesk (like mine is at the time of searching through this question) then you may not have later PHP versions in /usr/bin

    In this case, your PHP versions will be located in /opt/plesk/php so you can instead use the following command as a super user (run su first if you're not a super user) to set your PHP CLI version (to 7.3 in this example):

    echo "alias php='/opt/plesk/php/7.3/bin/php'" >> ~/.bashrc
    

    Log out and log back in and.... voila!

    Notes

    1. You must be have super user privileges to run this
    2. If you want to set the CLI to a different version then simply replace the 7.3 in the command to whichever version you would like (in the OP's case this would be 5.6
    3. If you want to check which versions Plesk has available for you to use, simply run: ls /opt/plesk/php

    Source: Plesk Support

提交回复
热议问题