Ok well I have spent a long time via different methods to do this.

I tried using mod_fastcgi but then went to mod_proxy_fcgi and apache 2.4. Due to the fact that so much shit breaks in 2.4 with ruby, python, perl and many other things I have got back to 2.2.

Well out of a stoke of luck from lots of googles, i found a module to allow EXACTLY what I needed. mod_fastcgi_handler.

This requires 1 line of code and will connect to PHP-FPM via either UNIX sock or TCP/IP.

My mod uses unix for efficiency. Now an example is AddHandler fcgi:/var/php/ .php

I have debated on whether to release this or not. I thought it would be just more hassle than its worth to keep patching files…

This is technical V2 of my mod.

Now you need apache2-dev (debian-based) or http-devel (centos/redhat/fedora).

Download and compile via instructions. Then enable in apache2.

Take the modified files from the link at the bottom and overwrite in the virtual-server module and restart webmin. These are for virtualmin 3.93.

After you need php5-fpm/php-fpm installed.

You will find a new php mode. Use it and enjoy.

To the devs, I know ALOT of ppl have asked for this and there was no good way to do it. I don’t know how this interacts with suexec, but every domain, sub-domain/sub-server has its own pool running as the user its under so permissions would apply.

I hope you add this into VM so I don’t need to keep re-hacking as this is a very good system IMHO.

Thanks for reading and I hope you enjoy my work.



Oh and I am not sure WHY this is happening but I am having to use:

if (&has_command(“php-fpm”) || &has_command(“php5-fpm”)}) {

instead of

if ((&has_command(“php-fpm”) || &has_command(“php5-fpm”)) && $apache::httpd_modules{‘mod_fastcgi_handler’}) {

Because the module isn’t in the hash even when enabled and it doesn’t make sense. Is there an apache module cache someplace?

I also updated the zip file and made structured folders as well as a script for the module.

Also a small note. You need to chmod /var/php to 755 or higher as it gets set at 000. If you don’t you will get a internal server error.

Dude this is awesome! I’ve just started researching PHP FPM, and I was hoping that it had some way of running in Virtualmin. Thank you very much for releasing this! I hope the devs see it and work on incorporating it into Virtualmin!

When I have the time, I’ll give this a shot on my test CentOS server.

Oh, and have you thought about uploading the code to a Github repository?

Hmm, looking at the mod_fcgi_handler link above, it looks like the author is no longer supporting the project.

Is this project the best alternative available, or would something like mod_proxy_fcgi work?

Thats the technical gotcha.

If you read i was on 2.2 THEN went to 2.4.

I coded this for the proxy directives bit too much shit was unsupported and I had to use custom deb’s and a whole bunch of mess. That was with mod_proxy_fcgi.

This is the only way I have gotten it to work repeatedly as I can not get mod_fastcgi to work as I need.

So if its un-maintained that isn’t good but I will be using this in my hosting company until apache 2.4 is more mainstream. I can’t stand FCGID as its a ram hog with many websites. ATM our servers generally don’t go over 1.5 GB ram and thats with everything running. At time of writing this our server with our hosting site is using 1.47 GB ram and is extremely fast.

I’ve been working on PCI compliance and really need to upgrade to Apache 2.4.2. It’s been a very frustrating process so far! My hosting company tells me that I can do it manually, but then ANY software updates will not work under the Virtualmin GUI. (I assume yum update would work fine).

Just to confirm, is this a workaround to install 2.4.2 and helpfully not break anything? Incidentally, I found a walkthrough to installing all of this from scratch (, but haven’t tested it.

Any feedback would be appreciated. I love Webmin but dislike that the newest version isn’t supported officially.

This mod working with nginx?

On a production server, is there STILL no way to run FastCGI with PHP-FPM or has something changed recently?


I am not quite following, why would you stop using mod_fastcgi and go to the mod_fastcgi_handler?

Does mod_fastcgi no longer work under Apache 2.4 ?

Oooh I see this comment on nginx “mod_fastcgi 2.4.6 no longer compiles against the Apache 2.4 tree”

Here is a version that does

Because I want to use APC caching, and FCGID wastes memory, as it keeps one cache per process. In order to use APC properly in apache < 2.4, you need to use FASTCGI/PHP-FPM.

To sum it up: AFAIK, in Apache 2.4 you can use APC with PHP 5.3. In PHP 6 you will be able to use APC (it’s built in) even with Apache < 2.4


Ah okay, I definitely understand the multiple cache problem, didn’t know this solved that. I think the other solution is to run it as apache/nobody which just makes one big process/cache for the one user.

But you can’t do that on a shared environment, correct? Regardless, does virtualmin natively support running it as apache/nobody ?

Hi, Are these instructions still valid? I’ve just run through the steps and come across a per execution error

HTTP/1.0 500 Perl execution failed Server: MiniServ/1.630 Date: Wed, 3 Jul 2013 18:37:02 GMT Content-type: text/html; Charset=iso-8859-1 Connection: close

Error - Perl execution failed

Undefined subroutine &virtual_server::get_domain_web_ssi called at /usr/libexec/webmin/virtual-server/edit_phpmode.cgi line 100.

patch for the latest version ?

also why has this not been implemented in core yet ?

I just posted a working setup to get virtualmin working with NGINX and PHP-FPM:

thanx emilorol,
but i much prefer the other way, as it still keeps the security of virtualmin by running each website as it own user and as far as i can see in that post, it is running all on the nginx user.

Yes, the setup run all sites under the nginx user and that is why I mention:

You might have to weight your needs against the benefits of this setup.

Maybe the Virtualmin developers will have mercy and finish the so needed module in a world where VPS are taking over and their price continuously dropping.

Hi @skelgaard,

I found a way to have PHP-FPM run as the domain user.

Please take a look and let me know.