• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

How to enable and run Apache with php5-fpm not php5-cgi?

M

MarkusLotus

Guest
Hi
just installed everything
is there any easy way to enable mod_fastcgi with php-fpm? instead of fcgid

in cpanel it was pretty easy to do, just add this in virtual host include:
Main::Service Configuration::Apache Configuration::Include Editor
<IfModule mod_fastcgi.c>
FastCGIExternalServer /usr/sbin/php-fpm -host 127.0.0.1:9000
AddHandler php-fastcgi .php

Action php-fastcgi /usr/sbin/php-fpm.fcgi
ScriptAlias /usr/sbin/php-fpm.fcgi /usr/sbin/php-fpm

</IfModule>

but it doesnt wokr with plesk, it keep running as php5-cgi
i have changed everything, maybe i forgot something?


thank you
 
Last edited by a moderator:
Hi Markus,

It is possible in Plesk 10/11. You should override Plesk fcgid handler in vhosts template file:

/usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php
/usr/local/psa/admin/conf/templates/default/service/php_over_fastcgi.php

HOWEVER, it is not recommended to modify these files directly, since your changes will be lost after Plesk upgrade.
INSTEAD, you should put your customizations into
/usr/local/psa/admin/conf/templates/custom/

Here is a doc that describes how to do this:
http://download1.parallels.com/Ples...figuration-guide/index.htm?fileName=64628.htm
 
could you please show me exactly where and how to change it?
i have tried everything... i am lost

it will be some normal official mod, so everyone will use it anyway.
this is how i paste it in cpanel incudes
LoadModule fastcgi_module modules/mod_fastcgi.so

<IfModule mod_fastcgi.c>
FastCGIExternalServer /usr/sbin/php-fpm -host 127.0.0.1:9000
AddHandler php-fastcgi .php

Action php-fastcgi /usr/sbin/php-fpm.fcgi
ScriptAlias /usr/sbin/php-fpm.fcgi /usr/sbin/php-fpm

<Directory /usr/sbin>
Options ExecCGI FollowSymLinks
SetHandler fastcgi-script
Order allow,deny
Allow from all
</Directory>
</IfModule>




this is insane, why there is files *fastcgi* but inside we have <IfModule mod_fcgid.c>
why we cannot just use real fastcgi module?


thank you
 
Last edited by a moderator:
Markus,

Plesk out of the box has built-in support for mod_fcgid, not mod_fastcgi.
Client can tweak this and use mod_fastcgi instead. However, this assumes that custom vhost config template must be created.

The attached link above describes this process.
 
i just dont understand why it so complicated...
to change just one server port i have to know all possible templates to edit, then mysql misc, then why do we need apache2/ports.conf??

ok i think i did everything, but when i open my site i get default plesk front page.....
i dont know whats behind your plesk core and how it works, but i need just to change SERVER PORT.

i give up, lol...
 
Markus,
As I mentioned before, Plesk supports mod_fcgid, not mod_fastcgi.
If you would like to see user friendly switch between mod_fcgid and mod_fastcgi, then I suggest for you to fill a feature request form.

You can find the request form here:
http://forum.parallels.com/showthread.php?t=106113

Please fill it carefully and post it here, in this thread. Then I will handover it to Plesk devs.


Thanks!
 
i think "panel" developers do not understand the difference between mod_fcgid and mod_fastcgi.
 
Hi Markus,

It is possible in Plesk 10/11. You should override Plesk fcgid handler in vhosts template file:

/usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php
/usr/local/psa/admin/conf/templates/default/service/php_over_fastcgi.php

HOWEVER, it is not recommended to modify these files directly, since your changes will be lost after Plesk upgrade.
INSTEAD, you should put your customizations into
/usr/local/psa/admin/conf/templates/custom/

Here is a doc that describes how to do this:
http://download1.parallels.com/Ples...figuration-guide/index.htm?fileName=64628.htm

Thanks for this info. I created the folders for making my customizations and I copied over the php_over_fastcgi.php. My question is, what exactly do I need to change in the php_over_fastcgi.php in order to switch FROM mod_fcgid TO --> mod_fastcgi ?
 
Same here (as boomshadow),
what exactly do we have to change??
My question is, what exactly do I need to change in the php_over_fastcgi.php in order to switch FROM mod_fcgid TO --> mod_fastcgi ?

Thanks,
Altec
 
Thanks for this info. I created the folders for making my customizations and I copied over the php_over_fastcgi.php. My question is, what exactly do I need to change in the php_over_fastcgi.php in order to switch FROM mod_fcgid TO --> mod_fastcgi ?


I'm having the same issue, did you ever get to the bottom of it?

One of the many things I've been trying was editing the fcgid.conf and changed FcgidProcessLiftTime 120, now APC lasts for around 2 mins instead of around 30 seconds it was.
 
Thanks for this info. I created the folders for making my customizations and I copied over the php_over_fastcgi.php. My question is, what exactly do I need to change in the php_over_fastcgi.php in order to switch FROM mod_fcgid TO --> mod_fastcgi ?

Did you solve the probem ?
 
I'm having the same issue, did you ever get to the bottom of it?

One of the many things I've been trying was editing the fcgid.conf and changed FcgidProcessLiftTime 120, now APC lasts for around 2 mins instead of around 30 seconds it was.

Did you solve the fast cgi probem ?
 
Markus (and all others),

The primary question should be why mod_fastcgi should be preferred over mod_fcgid.

Somehow, you did ignory the above mentioned (primary) question.

In short, mod_fcgid and mod_fastcgi are similar and only differ in the following:

a) mod_fcgid is, in the case of Plesk installations, a specific tuned version of the generally available mod_fcgid,

b) mod_fastcgi should be somewhat faster (but that is dependent on proper configuration),

c) mod_fastcgi and mod_fcgid differ slightly in the way they should be configured.

The core of the above is that you should prefer Plesk installations to run with mod_fcgid, given that it is often fast enough, prevents fuzz with configuration and breakdowns when upgrading.

The introduction of mod_fastcgi in Plesk installations does not yield significant extra speed, given that other modules for Apache in Plesk are already designed to result in speed.

In short, for gaining insignificant (and often unnecessary) extra speed, you risk a lot of work and a troublesome or even an unstable system.

It is adviced to NOT use mod_fastcgi (as a result of various tests, we can state that as a fact).
 
Markus (and all others),

The primary question should be why mod_fastcgi should be preferred over mod_fcgid.

Somehow, you did ignory the above mentioned (primary) question.

In short, mod_fcgid and mod_fastcgi are similar and only differ in the following:

a) mod_fcgid is, in the case of Plesk installations, a specific tuned version of the generally available mod_fcgid,

b) mod_fastcgi should be somewhat faster (but that is dependent on proper configuration),

c) mod_fastcgi and mod_fcgid differ slightly in the way they should be configured.

The core of the above is that you should prefer Plesk installations to run with mod_fcgid, given that it is often fast enough, prevents fuzz with configuration and breakdowns when upgrading.

The introduction of mod_fastcgi in Plesk installations does not yield significant extra speed, given that other modules for Apache in Plesk are already designed to result in speed.

In short, for gaining insignificant (and often unnecessary) extra speed, you risk a lot of work and a troublesome or even an unstable system.

It is adviced to NOT use mod_fastcgi (as a result of various tests, we can state that as a fact).

dear trialotto thank you for valuable information. I also prefer default fcgid configuration.

But I want to use opcode engine like APC or XCache. But they are not suitable with FastCGI.

I read that if I use PHP-FPM I can get optimum performance from opcode. What would you recommend for opcode in Plesk 11.5 and Apache with using FastCGI ?
Thank you
 
Mavera2,

In response to the quote

But I want to use opcode engine like APC or XCache. But they are not suitable with FastCGI.

it can be simply stated that APC is well-maintained (mature) and suitable for the standard Plesk 11.5.30 PHP version (5.3.10) and accompanying Zend Engine version (2.3.0), but

- one of its main contributors (Facebook) has already shifted focus to different PHP accelarators,
- the creators of PHP and Zend Engine are not inclined anymore to include it in the PHP core (they shifted focus to other accelerators as of PHP 5.5)

and it can also be stated that XCache is stable and has full support for PHP version 5.4, but is a somewhat deviant alternative to accelerators to be included in the PHP core.

Furthermore, the above mentioned accelerators are often only useful in large PHP applications (and really, in a standard Plesk installation, these large applications are absent).

In short, the mod_fcgid in Plesk installations will suffice in many occasions and it is certainly not wise to install APC (due to the facts that it will become obsolete and/or the standard mod_fcgid does more or less the same thing) or to install XCache (not really an advantage over the standard mod_fcgid).

I read that if I use PHP-FPM I can get optimum performance from opcode. What would you recommend for opcode in Plesk 11.5 and Apache with using FastCGI ?

The PHP-FPM module (to be installed with the Plesk autoinstaller) is a process manager, normally for mod_fastcgi and, in the case of Plesk, for the standard mod_fcgid.

The PHP-FPM option is, in short, intended to manage processes efficiently, giving major enhancements to fastcgi modules or alike modules.

Given an installation of both standard mod_fcgid and PHP-FPM, there really should not be a need to increase performance anymore (by accelerators or other modules).

In some cases performance is too little, implying that the application (causing low performance) should be migrated and isolated into a dedicated server, in which the application is run separately and, if and only if stand-alone deployment is not sufficient, some accelerators can be added, after and only after careful selection and testing of modules.

In conclusion, there should not be any need to add accelerators and/or other modules to Plesk.

The best result can (always) be obtained by isolating performance consuming applications to dedicated servers and creating a custom configuration and setup for those applications.

Kind regards......
 
Mavera2,

In response to the quote



it can be simply stated that APC is well-maintained (mature) and suitable for the standard Plesk 11.5.30 PHP version (5.3.10) and accompanying Zend Engine version (2.3.0), but

- one of its main contributors (Facebook) has already shifted focus to different PHP accelarators,
- the creators of PHP and Zend Engine are not inclined anymore to include it in the PHP core (they shifted focus to other accelerators as of PHP 5.5)

and it can also be stated that XCache is stable and has full support for PHP version 5.4, but is a somewhat deviant alternative to accelerators to be included in the PHP core.

Furthermore, the above mentioned accelerators are often only useful in large PHP applications (and really, in a standard Plesk installation, these large applications are absent).

In short, the mod_fcgid in Plesk installations will suffice in many occasions and it is certainly not wise to install APC (due to the facts that it will become obsolete and/or the standard mod_fcgid does more or less the same thing) or to install XCache (not really an advantage over the standard mod_fcgid).



The PHP-FPM module (to be installed with the Plesk autoinstaller) is a process manager, normally for mod_fastcgi and, in the case of Plesk, for the standard mod_fcgid.

The PHP-FPM option is, in short, intended to manage processes efficiently, giving major enhancements to fastcgi modules or alike modules.

Given an installation of both standard mod_fcgid and PHP-FPM, there really should not be a need to increase performance anymore (by accelerators or other modules).

In some cases performance is too little, implying that the application (causing low performance) should be migrated and isolated into a dedicated server, in which the application is run separately and, if and only if stand-alone deployment is not sufficient, some accelerators can be added, after and only after careful selection and testing of modules.

In conclusion, there should not be any need to add accelerators and/or other modules to Plesk.

The best result can (always) be obtained by isolating performance consuming applications to dedicated servers and creating a custom configuration and setup for those applications.

Kind regards......

Thank you.
I have a web applıcation that has daily 25k vısitors. In peak hours I see 350 visitors exist at the same time.

Until 8 months ago I was using shared hosting. Then I migrated to dedicated server. After the migration performance become well with mod_fcgid.

In peak hours my CPU usage is approx. 25-30%
Then I installed XCache and in peak hours my CPU usage became 11-12%.

Although XCache's very low uptime and all processes use their own memory, this performance boost came promising to me. Definetly my website's performance become better with opcode.

So I search a way to use opcode engine with fastcgi.
 
Last edited:
Mavera2,

It seems to me that the current dedicated server is not well-configured (or has a really low capacity with respect to memory and processors).

Maybe it is better to forget about APC, XCache (and all that) for a while.

Just try to test with PHP version 5.5, that includes Zend Opcache.

However, I must be somewhat strict: in a moderate application such as your website, some other simple solutions as

- reprogramming the website (to contain less dynamic pages),
- using better server-side code (many alternatives),
- using better site-structure (always improving performance),
- (minor) load balancing

would be more meaningful (than caching).

Kind regards
 
Is it possible to use PHP-FPM with mod_fcgid (or the supposedly modified version by Parallels)?
I don't think mod_fcgid support FastCgiExternalServer directive, is there another directive to be used here?

I have PHP-FPM working, by creating a custom vhost template and compiling custom php version with --enable-fpm


A basic idea of what I did:

open /usr/local/psa/admin/conf/templates/custom/service/php_over_fastcgi.php

Adjust the code like:

Code:
<?php if (strpos($VAR->domain->physicalHosting->phpHandlerId,'fpm') === false): ?>
<IfModule mod_fcgid.c>
<?php else: ?>
<IfModule mod_fastcgi.c>
<?php endif; ?>
    <Files ~ (\.php$)>
<?php if (strpos($VAR->domain->physicalHosting->phpHandlerId,'fpm') === false): ?>
        SetHandler fcgid-script
        FCGIWrapper <?php echo $VAR->server->webserver->apache->phpCgiBin ?> .php
<?php endif; ?>
        Options +ExecCGI
    </Files>
</IfModule>


<?php
exec('create_fpm ' . $VAR->domain->physicalHosting->phpHandlerId . ' ' . $VAR->domain->asciiName . ' ' . $VAR->domain->physicalHosting->login . ' ' . $VAR->server->webserver->clientGroup);
?>


open /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php
goto 138
insert:

Code:
<?php if (strpos($VAR->domain->physicalHosting->phpHandlerId,'fpm') !== false): ?>
<IfModule mod_fastcgi.c>
    AddHandler php5-fcgi-<?php echo $VAR->domain->asciiName ?><?php echo $OPT['ssl'] ? ".ssl" : ""; ?> .php
    Action php5-fcgi-<?php echo $VAR->domain->asciiName ?><?php echo $OPT['ssl'] ? ".ssl" : ""; ?> /php5-fcgi-<?php echo $VAR->domain->asciiName ?><?php echo $OPT['ssl'] ? ".ssl\n" : "\n"; ?>
    Alias /php5-fcgi-<?php echo $VAR->domain->asciiName ?><?php echo $OPT['ssl'] ? ".ssl" : ""; ?> /var/www/cgi-bin/php5-fcgi-<?php echo $VAR->domain->asciiName ?><?php echo $OPT['ssl'] ? ".ssl\n" : "\n"; ?>
    FastCgiExternalServer /var/www/cgi-bin/php5-fcgi-<?php echo $VAR->domain->asciiName ?><?php echo $OPT['ssl'] ? ".ssl" : ""; ?> -idle-timeout 60 -socket /var/run/php<?php echo $VAR->domain->physicalHosting->phpHandlerId ?>/<?php echo $VAR->domain->asciiName ?>.sock -pass-header Authorization
</IfModule>
<?php endif; ?>


The best solution would be for Parallels to make an extra phpHandlerType (module, cgi, fastcgi) named fpm.
And their own wrapper to dynamically create FPM sockets and configuration files per vhost.

I do this myself by calling a custom bash script named create_fpm.


Anyway, these snippets should help others integrate PHP-FPM into Plesk Panel.
 
Last edited:
Through Plesk 11.5 add components screen I installed nginx and php-fpm
Built my own copy of PHP 5.5.7
Setup domain through Plesk panel to use nginx and php-fpm.
When ran phpinfo() on a site it showed PHP 5.3.3

How to get the 5.5.7 version of php-fpm service running?

Solved the problem with the following change to /etc/init.d/php-fpm :
....
# BRAINFORGE 2013/12/30 Uses PHP 5.5
# daemon --pidfile ${pidfile} /usr/sbin/php-fpm --daemonize
daemon --pidfile ${pidfile} /usr/local/php-5.5/sbin/php-fpm --daemonize
....

However, under PHP settings in Plesk panel it shows the PHP version as 5.3.3 - confusing for other people.
Also there is the risk that one day some update will overwrite /etc/init.d/php-fpm

This information might help someone.
But has someone found a better (or the proper!) way of doing this?
 
Back
Top