Articles in this section

How to set another default PHP version for new subscriptions in Plesk?

Plesk for Windows kb: how-to Plesk for Linux ABT: Group B

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

Question

Currently, new domains are being created with an unwanted PHP version.

  • How to set another default PHP version for new subscriptions?

  • How to change the default PHP version/handler assigned for newly created service plans?

Answer

Via Plesk Interface

Change the PHP version for one existing subscription:
  1. Log into Plesk.

  2. Go to Subscriptions > example.com > Websites & Domains > Hosting Settings > PHP version.

  3. Now select the wanted PHP Version, for example, 7.2.11, then scroll down and press OK:
    2018-10-16_15_05_45-PHP_Settings_for_example.com_-_Lschuenke.png

Change the PHP version for all newly created Subscriptions using some Service Plan:

Note: This method will also change the PHP Versions of existing subscriptions if the Common PHP settings management permission is not set.

  1. Log into Plesk.

  2. Go to Service Plans select the wanted Service Plan, for example, Unlimited and select the tab PHP Settings.

  3. Now select the wanted PHP Version, for example, 7.2.11, then scroll down and press OK:
    2018-10-16_15_41_47-Unlimited_-_Lschuenke.png

Note: The steps have to be repeated for each Service Plan, in which the PHP Handler should be updated.

Change the PHP version for all newly created Service Plans:

This functionality is yet to be implemented in Plesk.

However, a corresponding request already exists on Plesk User Voice. Leave a vote there - top-ranked suggestions are likely to be included in next versions of Plesk.

As a workaround it is possible to create 2 event handlers (for service plans created by the administrator and by resellers), which will setup wanted PHP version and handler for future service plans:

  1. In Plesk go to Tools & Settings > Event Manager and click Add Event Handler

    1.png

  2. Select the event Service plan of administrator created and paste the command below to the Command field:

    CONFIG_TEXT:/usr/local/psa/bin/service_plan -u "$(plesk db -Ne'select name from Templates ORDER BY id DESC LIMIT 1;')" -owner $(plesk db -Ne'select login from clients where id = (select owner_id from Templates ORDER BY id DESC LIMIT 1);') -php_handler_id plesk-php71-fpm

    2.png

  3. Create an additional event handler for Service plan of reseller created and paste the command below to the Command field:

    CONFIG_TEXT:/usr/local/psa/bin/service_plan -u "$(plesk db -Ne'select name from Templates ORDER BY id DESC LIMIT 1;')" -owner "$(plesk db -Ne'select login from clients where id = (select owner_id from Templates ORDER BY id DESC LIMIT 1);')" -php_handler_id plesk-php71-fpm

    Note: Instead of plesk-php71-fpm it is possible to use a different PHP handler, which is displayed in the PHP Handler list, which can be viewed by following the steps in Retrieve the PHP Handler table

Note: It might be possible, that Plesk does not allow managing service plans via the web interface, this can be the case for example for Web Admin Edition or Web App Edition, it is possible to manage them via command line utilities, as described below.

Via Command Line (CLI)

Retrieve the PHP Handler table:
  1. Connect to the server via SSH.

  2. Retrieve the PHP Handler table:

    # [root@host ~]# plesk bin php_handler --list
    id: display name: full version: version: type: cgi-bin: php-cli: php.ini: custom: status:
    cgi 5.4.16 by OS vendor 5.4.16 5.4 cgi /usr/bin/php-cgi /usr/bin/php /etc/php.ini false disabled
    fastcgi 5.4.16 by OS vendor 5.4.16 5.4 fastcgi /usr/bin/php-cgi /usr/bin/php /etc/php.ini false enabled
    fpm 5.4.16 by OS vendor 5.4.16 5.4 fpm /usr/sbin/php-fpm /usr/bin/php /etc/php.ini false enabled
    plesk-php56-cgi 5.6.38 5.6.38 5.6 cgi /opt/plesk/php/5.6/bin/php-cgi /opt/plesk/php/5.6/bin/php /opt/plesk/php/5.6/etc/php.ini true disabled
    plesk-php56-fastcgi 5.6.38 5.6.38 5.6 fastcgi /opt/plesk/php/5.6/bin/php-cgi /opt/plesk/php/5.6/bin/php /opt/plesk/php/5.6/etc/php.ini true disabled
    plesk-php56-fpm 5.6.38 5.6.38 5.6 fpm /opt/plesk/php/5.6/sbin/php-fpm /opt/plesk/php/5.6/bin/php /opt/plesk/php/5.6/etc/php.ini true disabled
    plesk-php70-cgi 7.0.32 7.0.32 7.0 cgi /opt/plesk/php/7.0/bin/php-cgi /opt/plesk/php/7.0/bin/php /opt/plesk/php/7.0/etc/php.ini true disabled
    plesk-php70-fastcgi 7.0.32 7.0.32 7.0 fastcgi /opt/plesk/php/7.0/bin/php-cgi /opt/plesk/php/7.0/bin/php /opt/plesk/php/7.0/etc/php.ini true disabled
    plesk-php70-fpm 7.0.32 7.0.32 7.0 fpm /opt/plesk/php/7.0/sbin/php-fpm /opt/plesk/php/7.0/bin/php /opt/plesk/php/7.0/etc/php.ini true disabled
    plesk-php71-cgi 7.1.23 7.1.23 7.1 cgi /opt/plesk/php/7.1/bin/php-cgi /opt/plesk/php/7.1/bin/php /opt/plesk/php/7.1/etc/php.ini true disabled
    plesk-php71-fastcgi 7.1.23 7.1.23 7.1 fastcgi /opt/plesk/php/7.1/bin/php-cgi /opt/plesk/php/7.1/bin/php /opt/plesk/php/7.1/etc/php.ini true disabled
    plesk-php71-fpm 7.1.23 7.1.23 7.1 fpm /opt/plesk/php/7.1/sbin/php-fpm /opt/plesk/php/7.1/bin/php /opt/plesk/php/7.1/etc/php.ini true enabled
    plesk-php72-cgi 7.2.11 7.2.11 7.2 cgi /opt/plesk/php/7.2/bin/php-cgi /opt/plesk/php/7.2/bin/php /opt/plesk/php/7.2/etc/php.ini true disabled
    plesk-php72-fastcgi 7.2.11 7.2.11 7.2 fastcgi /opt/plesk/php/7.2/bin/php-cgi /opt/plesk/php/7.2/bin/php /opt/plesk/php/7.2/etc/php.ini true disabled
    plesk-php72-fpm 7.2.11 7.2.11 7.2 fpm /opt/plesk/php/7.2/sbin/php-fpm /opt/plesk/php/7.2/bin/php /opt/plesk/php/7.2/etc/php.ini true enabled

    Note: These PHP handler ids may vary on your server, thus it is advised to check.

Change the default PHP version for all newly created Subscriptions using some Service Plan:
  1. Connect to the server via SSH.

  2. Change the PHP handler for the Unlimited service plan.

    # plesk bin service_plan -u "Unlimited" -php_handler_id plesk-php70-fpm
    The hosting plan 'Unlimited' was successfully updated.

    If the service plan belongs to a receller, specify the receller's name in the -owner option:

    # plesk bin service_plan -u "Unlimited" -php_handler_id  -owner "reseller" plesk-php70-fpm
    The hosting plan 'Unlimited' was successfully updated.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.