By | April 9, 2015


After a couple of days figuring how to get this setup working I was able to crack it, so I am sharing it with the world in case someone is in my situation.

Step 1:

I started with a minimum install of CentOS 6.5 64 bits, but it should work with other supported OSes as well. I am using a VPS for my setup.

Step 2:

I also wanted to run the latest PHP version ( 5.6.1 as of today ), so I installed an enable the “Remi” repository. To do that execute the following commands:

a) Get your system ready for virtualmin

yum install wget perl -y

b) Add the “Remi” repository

c) Edit your repository file to enable the “Remi” repository

vi /etc/yum.repos.d/remi.repo
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch
# WARNING: If you enable this repository, you must also enable "remi"

d) Now install the latest and greatest version of PHP (5.6.1 as of today)

sudo yum install php php-xml php-gd php-imap php-mysql php-odbc php-pear php-pgsql php-snmp php-xmlrpc php-mbstring php-fpm php-opcache -y

e) Verify PHP by running the following command:

[[email protected] ~]# php -v

and that should output:

PHP 5.6.1 (cli) (built: Oct  3 2014 07:28:16) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

Step 3:

Install Virtualmin, but since PHP is already installed on the system I decide to update the “” so that only one version of PHP is on the system. I also took this change to remove stuff I don’t use like Postgres.

a) Get Virtualmin


b) Edit the file


c) Install Virtualmin and login for the first time to complete the post installation wizard


Step 4:

Now it is time to install NGINX and the Webmin modules like it said here:

a) Stop Apache web server

/etc/init.d/httpd stop

b) Download and install NGINX

yum install nginx

c) Start NGINX

/etc/init.d/nginx start

d) Install the Webmin module to manage NGINX

yum install wbm-virtualmin-nginx wbm-virtualmin-nginx-ssl

Step 5:

Configure NGINX to use TCP connections instead of Unix sockets. I know that Unix sockets might bring an extra performance benefit, but until there is a Webmin module to manage NGINX and PHP-FPM I try to keep it as simple as possible. I will explain how to use sockets at the end.

a) Go to Webmin > Server > Ngnix Webserver > Module Config

Change Connect Nginx to PHP processes with from Socket files to TCP connections

Step 6:

Let’s now disable the default way Virtualmin execute PHP (php-cgi) so that when you create a new site it uses PHP-FPM instead of PHP-CGI. I haven’t been able to use PHP-FPM to run under the user account of the site, but since I only have one site hosted it is not a problem for me. You might have to weight your needs against the benefits of this setup.

a) Disable the PHP-CGI call when creating and/or running a site:

vi /usr/libexec/webmin/virtualmin-nginx/

Around line 1705 and 1706 find:

# Launch it, and save the PID
&start_php_fcgi_server_command($d, $cmd, $envs_to_set, $log, $pidfile);

Replace it with:

# Launch it, and save the PID
#&start_php_fcgi_server_command($d, $cmd, $envs_to_set, $log, $pidfile);

Step 7:

Let’s edit the PHP-FPM config file to make change the user from Apache to Nginx.

a) Edit the www.conf file

vi /etc/php-fpm.d/www.conf

Look for:

; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

Change it with:

; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

Step 8:

Now at this point PHP-FPM is not running, but your are ready to create your site. This is the only cabeat you have to consider when creating a new site. Since you told NGINX to use a TCP Connection the default connection will look for and that is the port PHP-FPM uses, but if PHP-FPM is running and using the port 9000 when the new site is created it will listed in You can manually adjusted later on, but to keep it simple I stop PHP-PFM when creating a new site.

a) Go ahead and create your new site

b) After this start PHP-PFM like this:

service php-fpm start

c) If you visit your site you will see a 403 error and that is because there is nothing in public_html.

d)Visit /home/SITE-ACCOUNT/public_html and add an index.php file

vi index.php

add and save:


e) Revisit the site and now you should see PHP information page with the latest PHP version and running from PHP-PFM. You are done.



So, you want to run PHP-FPM from an Unix Socket instead of a TCP connection? No problem.

a) Go to Webmin > Server > Ngnix Webserver > Module Config

Change Connect Nginx to PHP processes with from TCP connections to Socket files

b) Edit the PHP-FPM www.conf file

Add folder for socket

mkdir -p /var/run/php-fpm/

Edit config file

vi /etc/php-fpm.d/www.conf

Change the following line:

listen =


listen = /var/run/php-fpm/DOMAINNAME.socket

c) Go to Webmin > Server > Ngnix Webserver > Edit Configuration Files


fastcgi_pass localhost:9000;


fastcgi_pass unix:/var/run/php-fpm/DOMAINNAME.socket;
Сomments аrchive