• Plesk - Problems and Solutions

Plesk - php-fpm configured but still served via fastcgi

A Plesk-server running CentOS 6 shows the following warning in Apache's error_log and you would like to move from fastcgi to php-fpm:

[Thu Aug 13 06:19:16 2020] [warn] mod_fcgid: process 15723 graceful kill fail, sending SIGKILL

This message is logged when fcgi processes have reached their limit. Webserver connections often time out in this situation, which means that no websites are being served and that affects all webspaces on your server, not just those running fastcgi. In case you have not yet increased the default limits, you can give it a try and change /etc/httpd/conf.d/fcgid.conf accordingly:

  FcgidIdleTimeout 300 
  FcgidProcessLifeTime 300
  FcgidMaxProcesses 150 
  FcgidMaxProcessesPerClass 100 
  FcgidMinProcessesPerClass 0
  FcgidConnectTimeout 30
  FcgidIOTimeout 300 
  FcgidInitialEnv RAILS_ENV production
  FcgidIdleScanInterval 10

The preferred solution would be to configure all webaccounts to use php-fpm and tell Apache to pass php-scripts directly via its proxy module. This can be done via tcp sockets or unix domain sockets, e.g.

<FilesMatch "\.php$">
    SetHandler  "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>

Plesk uses unix domain sockets and that's why Apache cannot process php-fpm requests directly running CentOS 6. Tcp sockets would work but unix domain sockets need Apache version 2.4.10+ to be supported with Apache proxy module. Plesk additionally installs nginx as a reverse proxy in newer Plesk versions. That one can use php-fpm directly with unix domain sockets and other requests are just passed on to Apache transparently.

So basically it is possible to serve a webspace using php-fpm with CentOS 6 combining nginx and Apache, but there are some caveats:

  • nginx does not know abount .htaccess files. Rewrites like with mod_rewrite are possible but these have to be part of nginx configuration
  • php-files missing the .php extensions are not recognized which means those will again be processed by Apache fastcgi


Solutions

Check with plesk bin php_handler if the desired php version is available:

[root@server ~]# plesk bin php_handler --list
                  id:       display name:  full version:  version:    type:                         cgi-bin:                    php-cli:                        php.ini:  custom:  status:
                  cgi  5.3.3 by OS vendor         5.4.45       5.4      cgi                 /usr/bin/php-cgi                /usr/bin/php                    /etc/php.ini    false disabled
              fastcgi              5.4.45         5.4.45       5.4  fastcgi                 /usr/bin/php-cgi                /usr/bin/php                    /etc/php.ini    false  enabled
                  fpm  5.3.3 by OS vendor         5.4.45       5.4      fpm                /usr/sbin/php-fpm                /usr/bin/php                    /etc/php.ini    false  enabled
               module              5.4.45         5.4.45       5.4   module                 /usr/bin/php-cgi                /usr/bin/php                    /etc/php.ini    false disabled
      plesk-php72-cgi              7.2.32         7.2.32       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.32         7.2.32       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  enabled
      plesk-php72-fpm              7.2.32         7.2.32       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

Check with plesk db how your webspace is configured:

mysql> select * from domains where name='customerdomain.com';
+-----+------------+------------------+------------------+-------------+--------+---------+-----------+-------+-------------+-----------+-----------+--------------------------------------+---------+-----------+-------------+----------------+-----------------+----------------+-------------+------------------+---------------------+-------------+-----------+-----------+-----------+
| id  | cr_date    | name             | displayName      | dns_zone_id | status | htype   | real_size | cl_id | cert_rep_id | limits_id | params_id | guid                                 | overuse | vendor_id | webspace_id | parentDomainId | webspace_status | permissions_id | external_id | adminDescription | resellerDescription | description | gl_filter | icpStatus | icpPermit |
+-----+------------+------------------+------------------+-------------+--------+---------+-----------+-------+-------------+-----------+-----------+--------------------------------------+---------+-----------+-------------+----------------+-----------------+----------------+-------------+------------------+---------------------+-------------+-----------+-----------+-----------+
| 593 | 2018-11-19 | customerdomain.com | customerdomain.com |         670 |      0 | vrt_hst | 171896832 |   366 |         165 |         0 |         0 | 9c244582-d0ea-4f81-9543-d741497a592c | false   |         1 |           0 |              0 |               0 |              0 |             |                  |                     |             | on        |         0 | NULL      |
+-----+------------+------------------+------------------+-------------+--------+---------+-----------+-------+-------------+-----------+-----------+--------------------------------------+---------+-----------+-------------+----------------+-----------------+----------------+-------------+------------------+---------------------+-------------+-----------+-----------+-----------+
1 row in set (0.00 sec)

mysql> select * from hosting where dom_id=593;
+--------+-------------+--------------+-------+----------+------+-----------+---------------------+------+-------+--------+-------+-------------+-------------------------+------+-----------+------------+--------------+-------------------------------------------+-----------+----------------+-------------------+----------------+---------+----------+-------------+
| dom_id | sys_user_id | real_traffic | ssi   | ssi_html | php  | php_isapi | php_handler_id      | cgi  | perl  | python | asp   | asp_dot_net | managed_runtime_version | ssl  | webstat   | at_domains | write_modify | www_root                                  | webdeploy | certificate_id | traffic_bandwidth | max_connection | fastcgi | same_ssl | sslRedirect |
+--------+-------------+--------------+-------+----------+------+-----------+---------------------+------+-------+--------+-------+-------------+-------------------------+------+-----------+------------+--------------+-------------------------------------------+-----------+----------------+-------------------+----------------+---------+----------+-------------+
|    593 |         485 |            0 | false | false    | true | false     | plesk-php72-fastcgi | true | false | false  | false | false       |                         | true | webalizer | false      | NULL         | /var/www/vhosts/customerdomain.com/httpdocs | false     |            319 |                -1 |             -1 | true    | true     | false       |
+--------+-------------+--------------+-------+----------+------+-----------+---------------------+------+-------+--------+-------+-------------+-------------------------+------+-----------+------------+--------------+-------------------------------------------+-----------+----------------+-------------------+----------------+---------+----------+-------------+
1 row in set (0.00 sec)

Set your desired php fpm version as php handler:

[root@server ~]# plesk bin domain --update customerdomain.com -php_handler_id plesk-php72-fpm
PHP-FPM cannot work with Apache on this operating system. To use PHP-FPM with nginx, set the option nginx-serve-php to "true".

In this case the nginx-serve-php option was set to false, which means that Apache itself serves php-fpm. This would be our preferred solution but it requires Apache 2.4.10+ and therefore does not work with CentOS 6.

Configure nginx to serve php-fpm instead of Apache:

[root@server ~]# plesk bin domain --update customerdomain.com -nginx-serve-php true
SUCCESS: Update of domain 'customerdomain.com' completed.

Assert that nginx' proxy function is active so that all other requests are forwarded to Apache:

[root@server ~]# plesk bin domain --update customerdomain.com -nginx-proxy-mode true
SUCCESS: Update of domain 'customerdomain.com' completed.

You may also check your subscriptions:

[root@server ~]# plesk bin subscription --update-web-server-settings customerdomain.com -nginx-serve-php true

[root@server ~]# plesk bin subscription --update customerdomain.com -php_handler_id plesk-php72-fpm
SUCCESS: Update of domain 'customerdomain.com' completed.

If these suggestions do not work for you consider migrating the webaccount to a Plesk server running CentOS 8, which provides Apache 2.4.37. Remember, proxying with unix domain sockets is available starting version 2.4.10 in Apache proxy module.

Data protection info | Help us to optimize this site and allow cookies please - insights will not be passed on to third parties.
Decline Accept