# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
# ssl_prefer_server_ciphers on;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
example@ubuntu:/etc/nginx/sites-available$
第二部分,Zabbix编译安装和Web前面配置
1、zabbix编译安装的依赖包
#安装编译套件
sudo apt-get install build-essential
#安装php前端需要的包
sudo apt-get install libmysqlclient15-dev php5-gd php5-mysql
#安装zabbix需要的包,snmp\curl\ssl\fping
sudo apt-get install snmp libsnmp-dev snmpd libcurl4-openssl-dev fping
2、创建zabbix用户和zabbix组
sudo groupadd zabbix
sudo useradd -r -s /usr/sbin/nologin -g zabbix zabbix
3、下载zabbix源码包,并解压
wget
sudo tar -zxvf zabbix_2.4.5.orig.tar.gz -C /usr/local/src/
cd /usr/local/src/zabbix-2.4.5/database
4、数据库初始化
mysql -uroot -p -e"create database zabbix;"
mysql -uroot -p -e"grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
mysql -D zabbix -uzabbix -pzabbix < schema.sql
mysql -D zabbix -uzabbix -pzabbix < image.sql
mysql -D zabbix -uzabbix -pzabbix < data.sql
5、zabbix编译安装
cd ..
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl
sudo make &&sudo make install
#--with-net-snmp是启用SNMP协议
#--with-libcurl是监控web网站用的
#--enable-server只可在服务端上使用
#其它还有IPMI等,参阅./configure --help
ps:报错 configure: error: MySQL library not found 缺libmysqlclient15-dev
6、设置zabbix配置文件目录
sudo mkdir /etc/zabbix
cp conf/zabbix_* /etc/zabbix/
sudo chown -R zabbix:zabbix /etc/zabbix/
7、修改配置文件
sudo vim /et/zabbix/zabbix_server.conf
DBUser DBPassword这两个关键字,替换为前面mysqlDB中设置的用户和密码
8、设置zabbix开机启动
sudo cp misc/init.d/debian/zabbix-server /etc/init.d
sudo cp misc/init.d/debian/zabbix-agent /etc/init.d
cd !$
sudo chmod 755 zabbix-*
sudo update-rc.d zabbix-server defaults
sudo update-rc.d zabbix-agent defaults
9、zabbix web界面安装设置
sudo mkdir /usr/share/nginx/html/zabbix/
cd /usr/src/zabbix-2.4.5/frontends/
sudo cp -r php/* /usr/share/nginx/html/zabbix
在浏览器中打开开始web界面的setup
1) zabbix会检查php的设置
标红的是默认需要修改的参数,php的设置文件为/etc/php5/cgi/php.ini
sudo restart php-fpm restart
2) zabbix会检查mysql的设置
zabbix_server.conf 与 my.cnf 中有关mysql的pid sock 等文件的配置路径要一致
my.cnf socket = /tmp/mysql.sock
zabbix_server.conf DBSocket = /tmp/mysql.sock
ps:如果还是报错/var/run/mysqld/mysqld.sock连接不上
也许 sudo ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock 是一种解决办法
3) 最后,要手动将生成的设置文件zabbix.conf.php上传到/usr/share/nginx/html/zabbix/conf,zabbix默认用户是admin,密码是zabbix,登陆后一定要修改。
一些Zabbix相关教程集合:
CentOS 6.3下Zabbix安装部署