Pandora FMS Installation with Nginx

Go back to Pandora FMS documentation index

We are working on the translation of the Pandora FMS documentation. Sorry for any inconvenience.

NGINX+PHP-FPM Installation and configuration for Pandora FMS

Nginx is a reverse high availability web/proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols. It is free and open source software, simplified licensed by BSD. It is used by a large list of websites known as WordPress, Netflix, Hulu, GitHub, Ohloh, SourceForge, TorrentReactor and some parts of Facebook.

NGINX, an apache alternative that increases load times.

This guide explain step by step how to change webserver, in the case we are using Apache and we want to use NGINX, in a Centos 6 machine.

NGINGX Instalation

Firstable, stop Apache service:

service httpd stop 

Create a directory, in order to save all respositories there:

mkdir /root/temp ; cd /root/temp  

Download all NGINX repositories from, in this example we will choose Centos 6:


Agregar los repositorios:

rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm

Install NGINX

yum install nginx

Start the service:

service nginx start

Check that it is working properly. Open your browser and write http://<IP_HOST>/index.html, “Welcome to nginx!”should appear.

NGINX Configuration

Change the user and group owner of /var/www/html/ directory and all their subdirectories:

chown -R nginx:nginx /var/www/html/

You can keep /etc/nginx/nginx.conf file by default or you can change desired parameters:

user  nginx;

worker_processes  5;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/;

events {
    worker_connections  4096;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf; 
    ## en conf.d/ The line where we will add the server configuration.

Create a pandora.conf file at /etc/nginx/conf.d/ and remove or move all files .conf that exist in these directory.

nano /etc/nginx/conf.d/pandora.conf

Possible server configuration:

upstream php_backend {
    server unix:/tmp/php5-fpm.sock;  ## Socket path. 

    listen 80;
    server_name; ## Higly recommend to set private server ip, 
                              ## otherwise if you set it to "localhost" or ""  
                              ## you could get some errors.
    root /var/www/html;
    index index.php index.html;
    access_log   logs/pandora.log  combined; 
    client_max_body_size 500M;

        location ~* \.(png|jpg|jpeg|gif|ico)$ {
           expires 720h;
           log_not_found on;

        location ~* \.(css|js|xml)$ {
           gzip_static on;
           expires 720h;
           log_not_found on;

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_buffer_size 128k;
                fastcgi_buffers 4 256k;
                fastcgi_busy_buffers_size 256k;
                fastcgi_intercept_errors on;
                fastcgi_pass   php_backend;
                fastcgi_index  index.php;
                fastcgi_param  REQUEST_METHOD   $request_method;
                fastcgi_param  CONTENT_TYPE     $content_type;
                fastcgi_param  CONTENT_LENGTH   $content_length;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  QUERY_STRING     $query_string;

        location / {
                try_files $uri $uri/ $uri.php?$args;


Create the log directory:

mkdir /etc/nginx/logs/

Check if nginx is well configurated:

nginx -t

Restart nginx in order to get the new configuration:

service nginx restart

If you want to know more about NGINX, just check:

Php-fpm installation

Install php-fpm (Centos repositories got it already):

yum install php-fpm  

Check if the libraries bellow are installed, if not proceed to install it.

yum install php-­mbstring php-­gd php­-ldap php­-snmp graphviz php-­mysql

Php-fpm configuration

Edit the /etc/php-fpm.d/www.conf configuration file:

;listen =
listen = /tmp/php5-fpm.sock ; #Socket path.
;listen.allowed_clients =
;listen.owner = nobody
; = nobody
;listen.mode = 0666

listen.owner = nginx = nginx
listen.mode = 0666

user = nginx
group = nginx

Change the user and group owner of the /var/lib/php/session directory.

chown nginx:nginx /var/lib/php/session

APC optional installation:

yum install php-pecl-apc

You will be able to modify the APC configuration at /etc/php.d/apc.ini. This is an important parameter to have in mind, in order to speed up:

; The size of each shared memory segment, with M/G suffix

Start the service:

service php-fpm start

Start up at boot

Start up nginx and php-fpm at system boot sequence and stop Apache:

chkconfig httpd off
chkconfig nginx on
chkconfig php-fpm on


Remember to check nginx, php-fpm and console logs aswell (/var/www/html/pandora_console/pandora_console.log).

Logs de NGINX:



Logs de php-fpm:



NGINX and Apache comparative

The target of installing NGINX is the improved load time performance. Here we show a comparative analysis between two identical machines (same RAM, CPU and database), one of them using Apache and the other one using NGINX:

Main access menu: Apache: (4,81s)

NGINX: (4,46s)

Manage Monitoring access: Apache: (5,83s)

NGINX: (4,84s)

Go back to Pandora FMS documentation index