You are not logged in.

#1 2014-03-18 15:43:58

warm
Member
Registered: 2009-06-23
Posts: 45

nginx + php-fpm + cacti = fail [Solved]

Due to resent apache updates (2.2 -> 2.4) I got a problems with PHP and I decided to migrate from apache to nginx. There are two main services on my http server: nagios and cacti. I fought with them hard and I beat nagios but  cacti still does not give up. The last result with cacti fighting is that test file in cacti dir with <? phpinfo(); ?> shows output of phpinfo. It must mean that the PHP basically works but cacti does not. cacti shows blank pages (with empty page source, no html at all just one new line symbol).  No errors in log files.

There is issue: when 'display_errors = Off' in php.ini then I get in nginx.log:

"GET /cacti/ HTTP/1.1" 500 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0"

code 500. When 'display_errors = On' then I get the same string with code 200.

So I cannot find any errors or reasons why cacti does not works. Need help. My give up (c) :-).

Here is come configs:

# cat nginx.conf
error_log  /var/log/nginx/error.log debug;

worker_processes  1;
events {
        worker_connections  1024;
}
http {
        include                 mime.types;
        default_type            application/octet-stream;
        sendfile                on;
        keepalive_timeout       65;
        server {
                listen          80;
                server_name     myname.net;
                error_page   500 502 503 504  /50x.html;
                location = /50x.html {
                        root    /usr/share/nginx/html;
                }
        }
        server {
                listen                  443;
                server_name             myname.net;
                ssl                     on;
                ssl_certificate         /etc/httpd/conf/myname.net.crt;
                ssl_certificate_key     /etc/httpd/conf/myname.net.crt;
                ssl_session_timeout     5m;
                ssl_protocols           SSLv2 SSLv3 TLSv1;
                ssl_ciphers             HIGH:!aNULL:!MD5;
                ssl_prefer_server_ciphers       on;
                include /etc/nginx/conf/cacti.conf;
                include /etc/nginx/conf/nagios.conf;
        }
}
# cat /etc/nginx/conf/cacti.conf

location /cacti {
        index index.php;
        alias /usr/share/webapps/cacti;
        # enable php
        location ~ \.php$ {
                include fastcgi.conf;
                fastcgi_pass unix:/run/cacti.sock;
                fastcgi_param SCRIPT_FILENAME $request_filename;
        }
#       location ~ \.php$ {
#               root /usr/share/webapps/cacti;
#               #try_files $uri =404;
#               include /etc/nginx/fastcgi_params;
#               #fastcgi_pass 127.0.0.1:9000;
#               fastcgi_pass unix:/run/cacti.sock;
#               fastcgi_index index.php;
#               #fastcgi_param SCRIPT_FILENAME $request_filename;
#               #fastcgi_param SCRIPT_FILENAME /usr/share/webapps/$fastcgi_script_name;
#               #fastcgi_param SCRIPT_FILENAME $request_filename;
#               fastcgi_param DOCUMENT_ROOT /usr/share/webapps/cacti;
#               fastcgi_intercept_errors on;
#       }
}
# cat /etc/nginx/conf/nagios.conf 

location /nagios {
        auth_basic              "Restricted";
        auth_basic_user_file    /etc/nagios/htpasswd.users;
        index index.php;
        alias /usr/share/nagios/share;
        # enable php
        location ~ \.php$ {
                include fastcgi.conf;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $request_filename;
        }
        location ~ \.cgi$ {
                root /usr/share/nagios/sbin;
                rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
                include /etc/nginx/fastcgi_params;
                fastcgi_param AUTH_USER $remote_user;
                fastcgi_param REMOTE_USER $remote_user;
                fastcgi_param SCRIPT_FILENAME /usr/share/nagios/sbin$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT /usr/share/nagios/sbin;
                fastcgi_pass unix:/run/fcgiwrap.sock;
        }
}

P.S. nagios uses php onits page and it works with the same configuration. Also I've tried tcp socket in cacti.conf - the same result.

Last edited by warm (2014-03-19 05:41:10)

Offline

#2 2014-03-19 05:51:35

warm
Member
Registered: 2009-06-23
Posts: 45

Re: nginx + php-fpm + cacti = fail [Solved]

The problem was in the circumstances. After blind moving from apache to nginx php was not working first time. When I was trying to find a reason I changed php.ini several times and some other configs too. So I got working PHP and broken cacti.

Today I've opened arch wiki about cacti and began to do step by step recommendations given in the document. After tunning php.ini cacti has started to work. On the way I have upgraded everything :-) (usualy I do not upgrade cacti).

So the main problem was that nginx or php-fpm does not produce any debug informaton so I solved the problem by stupidly guessing.

Offline

Board footer

Powered by FluxBB