Multiple php versions with fastcgi under EA4

Syneic

Member
Mar 17, 2014
11
2
3
cPanel Access Level
DataCenter Provider
I've looked a bit into what i takes to run fastcgi with support for multiple php versions.
This is quite easy to do through cli.
As this needs the experimental repository, play at your own risk. ;)

# Install easy apache 4 experimental repository to add fastcgi modules to easyapache4.

yum install ea4-experimental

# Run easyapache 4 through whm and add fastcgi module as well as the php versions you want.
# Set fcgi as handler in php handlers under Multiphp manager in whm.

# Set default php in post_virtualhost_global.conf as the last one set will be used.

vi /usr/local/apache/conf/includes/post_virtualhost_global.conf

##
<IfModule fcgid_module>
FcgidWrapper /usr/local/cpanel/cgi-sys/ea-php56 .php
FcgidWrapper /usr/local/cpanel/cgi-sys/ea-php56 .php5
FcgidWrapper /usr/local/cpanel/cgi-sys/ea-php56 .phtml
</IfModule>
##

# Add FcgidWrapper for each php 7.x override.

vi /usr/local/apache/conf/includes/post_virtualhost_global.conf

##
<directory "/home/user/">
FcgidWrapper /usr/local/cpanel/cgi-sys/ea-php70 .php
</directory>
##

And that is it, this user should now run under php 7.0 opposed to default 5.6.

As for adding support for this through whm, it seems like all it should take is commenting out addhandler and the non default wrappers in php.conf and adding a:
<IfModule fcgid_module>
#FcgidWrapper /usr/local/cpanel/cgi-sys/ea-php56 .php
FcgidWrapper /usr/local/cpanel/cgi-sys/ea-php70 .php
</IfModule>
Under each virtualhost, either by commenting out the one not in use or simply only show the one in use.

Any thoughts ?

Happy webserving :)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Hello,

Keep in mind that while this workaround may allow it to function, it's unsupported and not guaranteed to work with all MultiPHP functionality. You can read more about this on the following feature request comment:

EasyApache 4 mod_fcgid

Is there any reason you prefer to use fcgid over PHP-FPM?

Thank you.
 

Syneic

Member
Mar 17, 2014
11
2
3
cPanel Access Level
DataCenter Provider
I've found it not to be as bulletproof as fastcgi unfortunately.
Right now i got "FcgidMaxProcessesPerClass 1" set for each virtualhost, i can easy set the same in fpm with 1 child per pool.
The problem comes when/if there is a huge number of requests against one pool, this for some reason also makes all other pools unresponsive and wont respond for hours or before fpm service is restarted.
I've tried to change settings like max_request, process_idle_timeout, process_control_timeout, emergency_restart_interval but haven't found a satisfactory solution compared to fastcgi where only the one virtualhost get affected.
 

Syneic

Member
Mar 17, 2014
11
2
3
cPanel Access Level
DataCenter Provider
I just tried to enable FPM on a fairly unoptimized wordpress installation on one of my servers and within 10 minutes the site bacame completly unresponsive, and the child was dead as in not serving anyone.
It did not respond with 503 either, just waiting for response.
When i restarted fpm service, then came the 503 and after a refresh everything worked as planned again.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Hello,

Feel free to open a support ticket using the link in my signature if you'd like us to help troubleshoot the issue with PHP-FPM on your system.

Thank you.