Configuring PHP Settings
Let's explore how to configure PHP settings, change the PHP version, and install additional PHP modules in the Fastpanel control panel.
Installing PHP Versions
To install a specific PHP version, go to the left menu and select "Settings" -> "Applications."
Find the desired version in the list and click on the installation icon:
You can install PHP versions starting from PHP 5.2. Please note that PHP 5.2 may not be available for the latest versions of some operating systems, such as Ubuntu 20.04 and 22.04, or Debian 11.
Changing the PHP Version for a Site
If you want to change the PHP version for a specific site, first install the required version following the instructions above.
Then follow these steps:
- Hover over the card of the desired site and select "Options."
- Go to the "PHP Handler" section.
- Choose the "FastCGI" operating mode and select the required PHP version from the list.
- Save the changes you made.
To ensure that the correct PHP version has been applied, create a file named info.php in your site's directory and add the following content:
<?php phpinfo(); ?>
Then, open a web browser and go to a link of the following format:
http://your-website-address/info.php
If everything is in order, you will see technical information about the selected PHP version.
Changing PHP CLI Version for a User
You can select different PHP versions for each user. This allows you to use a specific PHP version when working in the command line (CLI). These settings only affect the PHP version for the command line and cron tasks and will not change the PHP version for your websites.
In the left menu, go to the "Management" section and select "Users."
Click on the three dots in the row of the desired user and select "Edit User."
In the "PHP Version (CLI)" field, choose the required version and save the changes.
Using Alternative PHP Versions in CLI
Typically, the following command is used to execute scripts in the command line:
php /path/to/script.php
In this case, the main server PHP version will be used, even if a different version has been selected for the site.
If you have changed the PHP version for a user as described above, the selected version for that user will be used when executing the command, not the server-wide version.
If you need to run a script using a specific PHP version, specify the full path to the corresponding interpreter, for example:
/opt/php80/bin/php /path/to/script.php
Changing PHP Settings for a Site
You can also customize PHP settings for each site individually. To do this:
- Go to the main control panel page and select the card of the desired site.
- Then choose "PHP Settings."
- Find the required parameter in the list and click the "Edit" button to change its value.
After making the changes, don't forget to save them.
Changing Settings for a Specific PHP Version
You can also configure parameters for each installed PHP version. To do this:
Go to the left menu and select "Management" -> "PHP."
On the "PHP Settings" tab, choose the PHP version for which you want to change the settings.
Click the "Edit" button to edit the value of a specific parameter.
After making the changes, don't forget to save them.
Installing PHP Modules
To install PHP modules, follow these steps:
1. Open the left menu and go to "Management" -> "PHP."
2. On the "PHP Modules" tab, find the required module in the list and click the installation icon (plus icon).
3. You can also remove previously installed modules here by clicking the trash icon (trash can icon).
Changing PHP Operation Mode
You can choose one of the following PHP operation modes:
- Apache Module (mod_php): In this mode, the server-wide PHP version is used, and selecting an alternative version is not possible. Nginx is used as the frontend server, and Apache serves as the backend. Scripts are processed by the mod_php module, and Apache operates in MPM-ITK mode.
- CGI: In this mode, you can select alternative PHP versions. Apache is used as the backend, and a separate PHP process is created for each request.
- FastCGI: In this mode, you can choose alternative PHP versions as well. Similar to CGI, Apache is used as the backend, but FastCGI processes operate faster and more efficiently.
To select the PHP operation mode, go to the main control panel page, hover over the card of the desired site, and select "Options."
Then go to the "PHP Handler" section, choose the desired mode, and save the changes.
- If your site doesn't use .htaccess files, choose the PHP-FPM mode.
- If your site uses .htaccess files, and the main PHP version is suitable, select PHP as the Apache module.
- If your site uses .htaccess files and requires an additional PHP version, choose the FastCGI mode.
- CGI mode is the slowest and is recommended only in cases where the site doesn't function correctly with other modes.