Search code examples
phpubuntu-18.04laravel-forge

How to change php version to 8 in Laravel Forge server?


Ubuntu 18.04. Nginx.

The server used to be hosted by Laravel Forge. Now - no, in free swimming. There were no changes on the server - everything that was created and configured by Forge remained.

I see the PHP 8.1 version is installed along the path /usr/bin/*php8.1. How can I change the php version now? Directly on the server without the Forge web interface. Thanks.


Solution

  • In Terminal

    sudo update-alternatives --config php 
    

    will display all versions installed, choose a number selection if you want a version

    There are 3 choices for the alternative php (providing /usr/bin/php).
    
      Selection    Path             Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/php8.0   80        auto mode
      1            /usr/bin/php7.2   72        manual mode
      2            /usr/bin/php7.4   74        manual mode
      3            /usr/bin/php8.0   80        manual mode
    
    Press "enter" to keep the current choice[*], or type selection number: 2
    update-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in manual mode
    

    check current php version

    php --version