Webmin with Nginx and php-fpm for high performance
5 March, 2021 by
Webmin with Nginx and php-fpm for high performance
Administrator
| No comments yet


This article is to install NGINX, a free, open-source, high-performance HTTP server in webmin with php-fpm. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. Nginx is a lightweight webserver that supports most of the functionality of Apache. It is suited to websites that have a large amount of static content. Unlike traditional web servers, NGINX doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.

Installing Nginx in Webmin

Apache is the default web server installed in webmin and switching webserver apache to nginx is done, only if no virtual servers are created. Ideally the change should be done on a freshly installed system.

Please perform below steps after accessing your server over SSH.

On Centos

service httpd stop

chkconfig httpd off

On Debian

/etc/init.d/apache2 stop

update-rc.d apache2 remove
yum install nginx (Centos )

apt-get install nginx ( Debian based)

Start Nginx using below command

/etc/init.d/nginx start

Install the Webmin module to manage NGINX

yum install wbm-virtualmin-nginx wbm-virtualmin-nginx-ssl ( centos )

apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl ( Debian based)

If you need us to setup the sever with nginx or php-fpm with high performance, you can contact us for the setup. Either you can subscribe for our Server Management or use our Hourly server management

PHP-FPM

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. The main features include Adaptive process spawning,  Advanced process management with graceful stop/start, Accelerated upload support etc. PHP-FPM is a daemon process  which provides us with a new binary, called php-fpm, and a default configuration file called php-fpm.conf is installed in /etc.

For installation please follow below steps.

yum install php-fpm -y (  Centos)

apt-get install php-fpm ( Debian)

Now let’s 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. Please note that we implemented the same on a fresh server.

Edit the file ‘/usr/libexec/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl’ and replace the following entries to disable php-cgi call.

# 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);

Now edit the PHP-FPM config file to make change the user from Apache to Nginx.

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

Start php-fpm after updating the above settings and use below commands to restart it.

service php-fpm start ( Centos )

/etc/init.d/php-fpm start ( Debian based)

We completed setting up php-fpm with Nginx on webmin servers. Now on if we create a website through webmin and put a test php page, it should need to work. Please report any errors if you found any.

Sign in to leave a comment