Switching from fast_cgi to php-fpm

I am really really frustrated trying to get virtualmin OFF Fast_cgi and ONto php-fpm. I’ve been trying to get this done now for over a week now and nothing seems to be getting me closer. phpinfo() works but can’t get wordpress going. Looked at tons of posts about rewrite rules. From looking at the logs I think fast CGI is still not disabled. I have removed the fast_cgi startup script from /etc/init.d, edited /usr/share/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl and commented the start_php_fcgi_server_command on line 1710, put return; statements in the subs related to starting fast_cgi in that script, yet the logs reflect fast_cgi still runs.

I really hate to start over from scratch again (install w/vmin, nginx module, firewall security plugin, domain setup, DB setup, etc etc. Takes an hour or so, and I was careful last time and am doubtful if it would do any good anyway. I saw a warning in the docs about not switching after domains are created, but no telling how old that doc is. Afaik it might be before the beta php-fpm support even existed.

I didn’t see anything in the original install concerning support for php-fpm, so I installed this guy’s module. I seem to recall stumbling across a different one that showed a radio button in the virtualmin UI for php-fpm or fast_cgi, but that tutorial / info was exclusively for an RPM / yum based (ie. non debian) OS and was pretty useless to me.

From phpinfo():
System Linux xxx.yyy.com 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64
Build Date Feb 8 2017 08:50:44
Server API FPM/FastCGI <--------------------------------------------- Why both?
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php5/fpm
Loaded Configuration File /etc/php5/fpm/php.ini
Scan this dir for additional .ini files /etc/php5/fpm/conf.d
… Under cgi-fcgi:
php-fpm active (only a sinlge line, followed by:)
cgi.discard_path 0 0
cgi.fix_pathinfo 0 0 <---------------------------- Does not reflect /etc/php5/fpm/php.ini which is 1
cgi.force_redirect 1 1
cgi.nph 0 0
cgi.redirect_status_env no value no value
cgi.rfc2616_headers 0 0
fastcgi.error_header no value no value
fastcgi.logging 1 1
fpm.config no value no value

Log file (/var/log/nginx/<domain.conf>) shows:2017/04/06 12:24:37 [error] 597#0: *4 FastCGI sent in stderr: “PHP message: PHP Warning: require(/home/one/public_html/wp-includes/load.php): failed to open stream: Permission denied in /home/one/public_html/wp-settings.php on line 19
PHP message: PHP Fatal error: require(): Failed opening required ‘/home/one/public_html/wp-includes/load.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /home/one/public_html/wp-settings.php on line 19” while reading response header from upstream, client: , server: .com, request: “POST / HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm-mydomain.com.sock:”, host: “”

  • OS is Debian 8.6
  • W/Vmin version is 1.831 / 5.07 (GPL)
  • webmin-virtualmin-nginx 2.2 -ssl 1.4
  • PHP Version 5.6.30-0+deb8u1

If I list processes with “ps aux | grep php” I see only the php-fpm processes running, so I presume it’s php-fpm serving up the phpinfo() page, and not fast_cgi, despite the log file output. That leads me to believe the issue is in w/vmin.

Rather than reset the VPS and start over I spun up a new vps instance to see if I have any better luck. I’ll refer to this as NEW vps, and the one I’ve been working with as OLD vps.

Using this guide (https://www.virtualmin.com/documentation/web/nginx), I was able to complete an installation on NEW vps with a clean report on the config re-check.

A ps aux | grep php showed the basic php-fpm processes running and no fast cgi before any virtual servers were created. When I created the first virtual server on NEW vps it created a php fast cgi server, at least according to the results below. Under Virtualmin–> Services NEW vps lists "configure nginx website AND “PHP 5 Configuration”, whereas the OLD vps only lists “Manage nginx php-fpm website”. Both had the preview website link there.

I created an index.php file in the public_html folder of the domain with <?php phpinfo(); ?> and hit it. “Bad Gateway” was the result, and error log showed the very same issues as OLD vps, that being a fast cgi error: "2017/04/06 16:43:58 [crit] 9453#0: *15 connect() to unix:/var/php-nginx/14915199569072.sock/socket failed (2: No such file or directory) while connecting to upstream, client:, server: , request: “GET /index.php HTTP/1.1”, upstream: “fastcgi://unix:/var/php-nginx/14915199569072.sock/socket:”, host: “”

Somebody PLEASE respond, I’m going nuts trying to figure this junk out ;(

Creating administration group tkm .. .. done Creating administration user tkm .. .. done Creating aliases for administration user .. .. done Adding administration user to groups .. .. done Creating home directory .. .. done Creating mailbox for administration user .. .. done Adding new DNS zone .. .. done Adding to email domains list .. .. done Adding default mail aliases .. .. done Creating Nginx virtual host .. .. done Starting PHP FastCGI server .. <--------------------------------------------------Why? .. done Adding webserver user www-data to server's group .. .. done Setting up scheduled Webalizer reporting .. .. done Setting up log file rotation .. .. done Creating MySQL login .. .. done Creating MySQL database tkm .. .. done Setting up spam filtering .. .. done Setting up virus filtering .. .. done Creating SSL certificate and private key .. .. done Adding SSL to Nginx virtual host .. .. done Creating Webmin user .. .. done Re-starting DNS server .. .. done Applying Nginx configuration .. .. done Re-loading Webmin .. .. done Saving server details .. .. done

This issue is RESOLVED, after lots of screwing around. It was due to differences between old and new vps servers and how the owner.groups were used. Had to change one folder to add group write perms too. Even got php5-fpm installed and working with this guy’s plugin which negates the need for the 2 nginx plugins from virtualmin. https://github.com/Real-Gecko/virtualmin-nginx-fpm/tree/master/install

Now the issue with with nameservers / DNS. I thought when Virtualmin created a new virtual server it setup the DNS with all of the necessary records for email etc. Virtualmin also reports an error when I try to enable bind on the features and plugins, complaining I need to disable bind or add to list of dns servers. Every time I do and click SAVE it comes right back to that same message. When I go back to add the features and plugins the bind feature is not checked, tho bind/named is running.

Seems like a lot of things need to be manually done in Virtualmin, which defeats the purpose of having it.