Help

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."

Configuring PHP Settings

Find the desired version in the list and click on the installation icon:

Configuring PHP Settings

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:

  1. Hover over the card of the desired site and select "Options."

Configuring PHP Settings

  1. Go to the "PHP Handler" section.
  2. Choose the "FastCGI" operating mode and select the required PHP version from the list.

Configuring PHP Settings

  1. 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."

Configuring PHP Settings

Click on the three dots in the row of the desired user and select "Edit User."

Configuring PHP Settings

In the "PHP Version (CLI)" field, choose the required version and save the changes.

Configuring PHP Settings

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:

  1. Go to the main control panel page and select the card of the desired site.
  2. Then choose "PHP Settings."

Configuring PHP Settings

  1. 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."

Configuring PHP Settings

On the "PHP Settings" tab, choose the PHP version for which you want to change the settings.

Configuring PHP 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."

Configuring PHP Settings

2. On the "PHP Modules" tab, find the required module in the list and click the installation icon (plus icon).

Configuring PHP Settings

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 works as the frontend server and Apache as the backend. Scripts are processed by the mod_php module, and Apache runs 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. CGI is the slowest mode; choose it only if the site does not work correctly in the other modes.
  • FastCGI: In this mode, you can choose alternative PHP versions as well. Similar to CGI, Apache is used as the backend, but FastCGI processes work faster and more efficiently.
  • PHP-FPM (Nginx + PHP-FPM): This mode lets you choose alternative PHP versions. Nginx works as the frontend server and PHP-FPM as the backend. The .htaccess file is not processed in this mode, so all .htaccess settings must be moved to the Nginx configuration. Choose this mode if the site does not use .htaccess. If the site uses .htaccess and the main PHP version suits it, choose PHP as an Apache module. If the site uses .htaccess and needs an additional PHP version, choose FastCGI.

To select the PHP operation mode, go to the main control panel page, hover over the card of the desired site, and select "Options."

Configuring PHP Settings

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.

Have more questions about Hosting?