Category Archives: Webmin

27Jul/16

Enable mpm-itk in Webmin

The Apache HTTP Server is designed to be a powerful and flexible web server that can work on a very wide variety of platforms. Apache web server shipts with a selection of Multi-Processing Modules (MPMs) which are responsible for binding to network ports on the machine, accepting requests, and dispatching children to handle the requests.  Two MPMs thats comes with Apache on Linux is prefork and worker.

What is the default apache module used ?

In webmin by default prefork MPM is enabled. mpm-itk is another type MPM thats supported by Apache.

What are the benifits of using mpm-itk ?

The apache2-mpm-itk or mpm-itk is an MPM (Multi-Processing Module) for the Apache web server. mpm-itk allows us to run each of our  website vhost under a separate uid and gid. in other words, the scripts and configuration files for one vhost no longer have to be readable for all the other vhosts.

mpm-itk is based on the traditional prefork MPM, which means it’s non-threaded. We can run non-thread-aware code (like many PHP extensions) without problems. On the other hand, We will also take an additional performance hit over prefork, since there’s an extra fork per request.

With mpm-itk we can enable php opcode caching like APC, Xcache etc.  This is one of the main benefits of mpm-itk when it compared to suphp.

The latest version is 2.4.7-04 for Apache 2.4 and 2.2.17-01 Apache 2.2.x.

Installation

Virtualmin running on Ubuntu

apt-get install apache2-mpm-itk

Virtualmin running on Centos

yum install httpd-itk

If get any errors like erros like unmet dependencies with apache2.2-common missing. First we need to install the apache2.2-common .deb or rpm package manually after downloading package.

We can use commands like dpkg -i *.deb (debian) or rpm -ivh *.rpm ( Centos) bases servers.

Once the installation is completed we need to configure the webmin for mpm-itk. mpm-itk is configured on a per-vhost basis. Which means we don’t have to set any global options, and there’s only one directive we need to set in a vhost, AssignUserId, which takes two parameters, the user name and the group that the vhost will run as.

In case of webmin we perform this action using the Server Templates option. For example, add this to Virtualmin Server Templates:

<ifmodule mpm_itk_module>
AssignUserId ${USER} ${USER}
</ifmodule>
15Jul/16

Webmin with Nginx and php-fpm for high performance

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.