[root@zabbix~]# cat /etc/redhat-release
CentOSrelease 6.3 (Final)
[root@zabbix~]# uname -a
Linux zabbix2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64GNU/Linux
[root@zabbix~]# vi /etc/yum.repos.d/nginx.repo ###这个需要自己创建
[nginx]
name=nginxrepo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
wq ###保存并退出
yum -yinstall gcc gcc-c++ mysql mysql-server yum -y install libjpeg* php-imapphp-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcryptphp-bcmath php-mhash libmcrypt libmcrypt-devel php-fpmphp-devel php-mysql php-mysqli php-pdo php-opcache php-gd nginx mysql mysql-server mysql-connector-odbc
[root@zabbix~]# chkconfig mysql on
[root@zabbix~]# chkconfig php-fpm on
[root@zabbix~]# chkconfig nginx on
[root@zabbix~]# netstat –lnt ###检查是否启动
ActiveInternet connections (only servers)
Proto Recv-QSend-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
1.修改/etc/php-fpm.d/www.conf的配置文件
sed -i‘s/user = apache/user = nginx/g‘ /etc/php-fpm.d/www.conf
sed -i‘s/group = apache/group = nginx/g‘ /etc/php-fpm.d/www.conf
sed -i‘s/;rlimit_files = 1024/rlimit_files = 51200/g‘ /etc/php-fpm.d/www.conf
sed -i‘s/^pm.max_children.*/pm.max_children = 300/g‘ /etc/php-fpm.d/www.conf
2.修改nginx的配置文件
[root@zabbix~]# more /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name 192.168.250.119[W用1] ;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php[W用2] index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the staticpage /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listeningon 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI serverlistening on 127.0.0.1:9000
#
========================配置支持php==============================
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html[W用3] $fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, ifApache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all;
#}
}
3.给站点目录授权
chown -Rnginx:nginx /usr/share/nginx/html/
[root@zabbix~]# /etc/init.d/nginx reload
重新载入 nginx: [确定]
[root@zabbix~]# /etc/init.d/php-fpm restart
停止 php-fpm: [确定]
正在启动 php-fpm: [确定]
[root@zabbix~]# more /usr/share/nginx/html/test.php
<?php
phpinfo();
?>
[root@zabbix~]#rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
[root@zabbix~]yum–yinstall zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get
mysql>createdatabase zabbix character set utf8;
mysql>grantall privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘;
mysql>flushprivileges;
[root@zabbix~]cd /usr/share/doc/[W用4] zabbix-server-mysql-2.2.0/create
# mysql -uroot zabbix < schema.sql ###我这个数据库没密码,数据库有密码还需要写上密码
# mysql -uroot zabbix < images.sql
# mysql -uroot zabbix < data.sql
1.需要下载源码包,因为yum安装的包里面没有zabbix php的站点目录
[root@zabbix~]wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz
[root@zabbix~]# tar zxvf zabbix-2.2.3.tar.gz
[root@zabbix~]# cd zabbix-2.2.3
3.复制php文件到站点目录下
[root@zabbixzabbix-2.2.3]# cp -r frontends/php/* /usr/share/nginx/html/
sed -i"s/;date.timezone =/date.timezone = Asia\/Shanghai/g" /etc/php.ini
sed -i"s#max_execution_time = 30#max_execution_time = 300#g" /etc/php.ini
sed -i"s#post_max_size = 8M#post_max_size = 32M#g" /etc/php.ini
sed -i"s#max_input_time = 60#max_input_time = 300#g" /etc/php.ini
sed -i"s#memory_limit = 128M#memory_limit = 128M#g" /etc/php.ini
sed -i"/;mbstring.func_overload = 0/ambstring.func_overload = 2\n"/etc/php.ini
DBName=zabbix数据库名称
DBUser=zabbix数据库用户
DBPassword=zabbix数据库密码
sed -i"s/DBUser\=root/DBUser\=zabbix/g" /etc/zabbix/zabbix_server.conf
sed -i"/# DBPassword=/aDBPassword=zabbix\n" /etc/zabbix/zabbix_server.conf
sed -i"s#tmp/zabbix_server.log#var/log/zabbix/zabbix_server.log#g" /etc/zabbix/zabbix_server.conf
在浏览器输入http://192.168.250.119/zabbix
数据库 ip 为 localhost
端口为 3306
数据库名 zabbix
用户为 zabbix
密码为 zabbix
点击 test connection,如果没有问题,则会提示 OK,否则,需要检查数据库授权是否正确
如果 此 处 提 示 文 件 zabbix.conf.php 无 法 创 建 ,有可能是nginx站点目录没有写入权限。
默认账户admin,密码zabbix
到此为止server端已经全部安装完毕。
[root@zabbixzabbix-2.2.3]# yum -y install zabbix-agent
[root@zabbix~]# grep -v "#" /etc/zabbix/zabbix_agentd.conf|grep -v "^$"
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.250.119 #允许哪些 ip 访问本机
ServerActive=192.168.250.119 #被动监控,服务端的 ip
Hostname=192.168.250.119 #客户端的主机名
Include=/etc/zabbix/zabbix_agentd.d/ #配置文件
[root@zabbix~]# /etc/init.d/zabbix-agent start
StartingZabbix agent: [确定]
[root@zabbix~]# chkconfig zabbix-agent on
简单监控一台主机
创建主机
选择第一种方式来进行监控,也可以用snmp的方式去监控
使用模版来进行监控,设置完成后点存档。
等1分钟左右,server就能检测到了。
简单的安装和监控就全部结束了。
[W用1]没有域名写成自己服务器的地址即可
[W用2]添加index.php
[W用3]我这边变量有问题,我就直接写上绝对路径,写上nginx的站点目录
[W用4]使用yum安装会把包下载到这个目录下
本文出自 “Toby专栏” 博客,请务必保留此出处http://toby1.blog.51cto.com/2688505/1431042
原文地址:http://toby1.blog.51cto.com/2688505/1431042