Switching kaltura installation to php-fpm

I have kaltura 11.7 installed and running.
I’m trying to switch the installation (for performance) to php-fpm, any recommendation for doing that?



We did that just last week and everything works but you need to make 3 changes:

  1. The html5 embed. The problem is that under php-fpm getallheaders() does not work.

You need to edit this file:


Go to $requestHeaders = getallheaders(); and patch the code this way:

if (!function_exists('getallheaders')) {
                function getallheaders() {
                        $headers = [];
                        foreach ($_SERVER as $name => $value) {
                                if (substr($name, 0, 5) == 'HTTP_') {
                                        $headers[str_replace(' ', '-', ucwords(s
trtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
                        return $headers;
$requestHeaders = getallheaders();

Be careful because you need to do it for every active player or each time you update your player.

  1. You also need to change the /etc/httpd/conf.d/php.conf and comment these two lines since it is handled by php-fpm:
#php_value session.save_handler "files"
#php_value session.save_path    "/var/lib/php/session"
  1. You need to edit enabled.kaltura.conf (under /opt/kaltura/app/configurations/apache/conf.d) and comment/fix this:
#php_flag engine off

Be careful because it is a security setting and everyone can upload a php executable !!

So far it has worked well and it’s a great relief from the archaic apache pre_fork model which really gave us a lot of performance headaches.



1 Like

Didn’t you need to change configuration in the kaltura conf files, only apache generic files?
Which apache version do you use?


I pressed Enter by mistake before finishing my post.


One last thing:

On enabled.kaltura.conf we added the cgi handler after the last Directory statement:

# Handler for PHP-FPM
<FilesMatch \.php$>    
        SetHandler "proxy:fcgi://"


I used Apache 2.4 and standard php 5.4 and php-fpm under Centos 7.


Hi all,

Following up on this since I’m about to release a version for CentOS/RHEL 8 where FPM is the default PHP SAPI.
Please see this pull for the configuration changes:

@david.eusse, @oferc1,

In particular, look at https://github.com/kaltura/server/pull/8942/files#diff-5ba96347d2f7e5465a08d0f1190931cdR251

This provides the same defense as the php_flag directive.