How to change PHP version on the command line (CLI) in FASTPANEL?

Introduction

FASTPANEL is an amazing open-source website hosting/management control panel that makes it very easy for common tasks like creating websites, emails and databases, uploading files, installing PHP versions, extensions and more through a simple web interface.

FASTPANEL offers a user-friendly approach to changing PHP versions, providing flexibility through both the command line interface (CLI) and the web interface. Users can effortlessly adapt their server environment to varying requirements using the method that best suits their preferences. Follow this step-by-step guide to seamlessly switch PHP versions on the CLI within FASTPANEL.

Prerequisites

Before you begin this guide, you’ll need to do the following:

  • Fastuser and root access to the server

Option 1: Command Line Interface (CLI)

Step 1: Access the Command Line Interface (CLI):

Open the command line interface on your server using an SSH client or local access.

Step 2: Navigate to the PHP Directory:

Use the “cd” command to navigate to the PHP directory, usually located in “/opt/php.”

cd /opt/php

Step 3: View Available PHP Versions:

List the installed PHP versions in the directory using the “ls” command.

ls

Step 4: Choose and Change PHP Version:

Identify the desired PHP version and use the “update-alternatives” command to set it.

sudo update-alternatives --set php /opt/php/phpX.X/bin/php

Replace “phpX.X” with the actual version you want to use.

Step 5: Verify PHP Version:

Confirm the change by checking the active PHP version.

php -v

Option 2: FastPanel Web Interface

Change PHP version on command line for specific user from FASTPANEL

Login to the FASTPANEL

FASTPANEL Menu > Management > Users > PHP (CLI) Version > Save

After login to the FASTPANEL, open the menu and click on “Users” to change the PHP version for a user, select the user (for whom you want to change the PHP version) and then edit the user and select the PHP version in the “PHP (CLI) Version” option and save.

Now, connect to the server via SSH user and you will see that the PHP version has now been changed.

Note: open a new SSH session, if you already connected to the server

Conclusion

By offering both CLI and web interface options, FastPanel ensures users can easily adapt their server’s PHP environment according to their preferred method. Whether you prefer the command line for precision or the web interface for simplicity, FastPanel caters to diverse user preferences.


Leave a Reply

Your email address will not be published. Required fields are marked *