今天终于把nginx+nagios在我自己的ubuntu机器下搭建起来,特此写一个教程,有2个目的,1作为备忘录留为己用,2作为新手教程指导。
1.安装nginx,在ubuntu下apt-cache search nginx可以搜索到nginx包,我安装的是0.7.65版本。
fcgiwrap - simple server to run CGI applications over FastCGI
collectd-core - statistics collection and monitoring daemon (core system)
nginx - small, but very powerful and efficient web server and mail proxy
nginx-dbg - Debugging symbols for nginx
php5-fpm - server-side, HTML-embedded scripting language (FPM binary)
2.此处列出了fagiwrap包以及php5-fpm包均是以后需要安装的包,如果搜索得到即可立即安装否则等待下面的步骤进行安装。安装方法:
sudo apt-get install nginx
3.nginx部署nagios需要安装fagiwrap以及php5-fpm,可以先进行安装,我安装的nagios3.2.0版本是不带有这2个ubuntu包的。
4.fagiwrap以及php5-fpm的安装方法:
参考我的另一篇文章
5.启动fcgiwrap以及php5-fpm服务,这里要记得修改2个包的配置文件,将运行方式修改为sock方式则可以在如下目录生成相应的socket文件unix:/var/run/fcgiwrap.socket,unix:/var/run/php5-fpm.sock,另fastcgi内包含大量的脚本文件cgi,这些脚本会在/etc/nginx/fastcgi_params目录下,如果你安装的fastcgi版本低,则该目录下是一个.conf的文件,修改php5-fpm的监听方式修改/etc/php5/fpm/php5-fpm.conf文件,找到如下位置并修改成这个样子
listen = /var/run/php5-fpm.sock
;listen = 127.0.0.1:9000
6.给nagios访问添加验证服务,创建一个nagiosadmin的用户用于Nagios的WEB接口登录。记下你所设置的登录口令,一会儿你会用到它
这里要借助于apche的htpasswd,在有apache机器上执行下列命令
/usr/local/apache2/bin/htpasswd -c /usr/local/server/nginx/conf/htppasswd nagiosadmin
7.修改nginx配置:
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 9999;
server_name 10.18.105.110;
auth_basic "Restricted Nagios Area!";
auth_basic_user_file /opt/nagios/etc/htpasswd.users;
charset utf-8;
root /usr/share/nagios3/htdocs ;
index index.html index.htm index.php;
location /nagios3/stylesheets {
alias /etc/nagios3/stylesheets;
}
location /nagios3/images {
alias /usr/share/nagios3/htdocs/images;
}
location ~ \.cgi$ {
root /usr/lib/cgi-bin/nagios3;
rewrite ^/cgi-bin/nagios3/(.*)$ /$1;
include /etc/nginx/fastcgi_params;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}}
}
8.配置文件内着重注意的地方1,root /usr/share/nagios3/htdocs ,nagios首页页面所在位置,不要定位到example的index页面上去,2,样式以及图片的过滤路径,有可能找不到需要你去配置,3.找不到cgi脚本报脚本名或者document root错误,4,fastcgi参数有include /etc/nginx/fastcgi_params;老版本可能是一个配置文件,而不是一个文件夹,5,fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name; 这里最好重新定位一下你的脚本在哪里,否则fastcgi自带的配置文件仍然报找不到脚本
参考文档:
在nginx上搭建nagios
ubuntu php5-fpm安装
Nagios with NginX in Ubuntu
How to serve nagios with nginx
分享到:
相关推荐
随着linux服务器可用性、稳定性逐步增强,企业对线上服务也要求越来越严格,需要有专门的监控系统监控服务的正常运转,并有问题及时发邮件、报警给linux SA。
Linux下nginx+nagios_监控平台搭建.doc
Linux下nginx+nagios监控平台搭建.pdf
通过nginx+keepalived+tomcat实现服务器负载均衡的高可用方案,解决传统负载均衡服务器宕机后无法自行切换从而导致雪崩效应的场景
Win+Nginx+PHP+MySQL环境搭建.docx
用FFmpeg+nginx+rtmp搭建环境实现推流
ffmpeg+nginx+nginx-rtmp-module搭建个人直播平台。 使用说明(ffmpeg+nginx+rtmp-module已经整合,支持HTTP,具体配置查看conf/nginx.conf): 1.解压后,运行nginx_start.bat。(查看监控状态 ...
RabbitMQ+Zookeeper+Dubbo+Nginx+Mysql+Redis搭建.txtRabbitMQ+Zookeeper+Dubbo+Nginx+Mysql+Redis搭建.txtRabbitMQ+Zookeeper+Dubbo+Nginx+Mysql+Redis搭建.txt
ubuntunginx+PHP+mysql服务器搭建.pdf
ubuntu nginx+PHP+mysql服务器搭建.pdf
ubuntunginx+PHP+mysql服务器搭建.rar
ubuntunginx+PHP+mysql服务器搭建参考.pdf
ubuntunginx+PHP+mysql服务器搭建资料.pdf
nginx+apache+mysql+php+memcached+squid搭建门户网站
ubuntu+nginx+tomcat 实现负载匀衡
Nginx + uwsgi + web.py 搭建web服务器, 也包含一整套python服务器后台框架代码,简单方便,容易搭建。
Nginx+Uwsgi+Django(python3)+Vue部署,一步步实现。网上找了N多篇文章都没成功,特意记录,以免其他同学踩坑
ubuntu离线部署nginx+fastdfs软件包 autoconf-latest.tar.gz automake-1.15.tar.gz fastdfs-5.11.tar.gz fastdfs-nginx-module-1.20.tar.gz libfastcommon-1.0.38.tar.gz m4-1.4.18.tar.gz openssl-1.1.0j.tar.gz ...
CentOS7 自动化搭建Nginx+PHP7+Mysql+Docker+Docker-Compose Shell脚本,Docker version 18.06.1-ce,docker-compose version 1.22.0