How to change PHP version
FASTPANEL® allows you to use alternative PHP versions for each site individually. You may install and use any PHP version starting from 5.2. You may apply any PHP version to your website starting from PHP 5.2
PHP 5.2 is not available on some new OSes, in particular on Ubuntu 20.04, 22.04 and Debian 11
This article covers the following points:
- How to change PHP version for website
- How to change PHP (CLI) version for the user
- How to use alternative PHP versions on the command line (CLI)
- How to use alternative versions in crontab scheduler
PHP version change through the example of PHP 7.4
Go to "Settings" -> "Applications" in the side menu
Find php74 application, click "Install" and wait until the installation is completed:
Open the card of the website that needs PHP changing and click on "Settings" menu
Perform the following actions:
Open "PHP settings" submenu
Select FastCGI as the PHP mode
Select PHP version needed in the PHP version field.
Click "Save" button.
When "PHP Version" will become active you may choose required PHP version, php74 in this particular case.
Instead of FastCGI you can also choose PHP-FPM or CGI, but in 95% of cases it is FastCGI that is suitable. More information about PHP modes you can find here
You may check if the correct PHP version is applied by creating info.php file in the root directory of your website with the following content:
<?php phpinfo(); ?>
After that open the file via Internet browser by following the alike link http://yourwebsite.com/info.php
If everything is done correctly you will see a page showing technical information about php 7.4
How to change PHP (CLI) version for the user
FASTPANEL® allows you to select PHP versions for each user individually. This action will allow you to access the alternative version of PHP on the command line using the normal php command.
This action influences only on PHP version in the command line and on the tasks in the crontab scheduler. PHP versions selected for the websites will remain unchanged.
To change the PHP version for the user, open the "Users" menu. Choose the user, click on the "Edit user" icon, and select a suitable version in the "PHP (CLI) version" field
After changing this feature, reconnect the server via SSH. In the previously opened sessions the PHP version will remain the same.
How to use alternative PHP versions on command line (CLI)
As a rule, to run scripts through the command line, the following command is used:
This way the main server PHP version will be used, even if an alternative one was chosen for the website.
If beforehand the PHP version was changed according the instructions in How to change PHP (CLI) version for the user, then the common php command will use the chosen user’s PHP version, not the server’s one.
How to use alternative versions in crontab scheduler
To run the script through the alternative version, you should change the php command to the full path to the alternative interpreter. In case of PHP 7.4 it will be
/opt/php74/bin/php, so the command will look like: