1、在已有的LAMP或者LNMP的基础上安装zabbix,安装一些依赖包:
yum -y install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenPMI-devel java-devel libxml2-devel
2、添加用户:
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin -m
useradd zabbix -g zabbix -s /sbin/nologin -m
3、创建数据库,添加授权账号
create database zabbix character set utf8; grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
4、编译安装zabbix
下载地址:wget
http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.0/zabbix-2.2.0.tar.gz
![zabbix2.2部署安装(安装环境Centos 6.* X64) zabbix2.2部署安装(安装环境Centos 6.* X64)](https://image.shishitao.com:8440/aHR0cHM6Ly93d3cuc2h1emhpZHVvLmNvbS9Vc2Vycy9UaWFudGlhbmRhcy9Eb2N1bWVudHMvTXklMjBLbm93bGVkZ2UvdGVtcC80OGQ5OTBiNC0yZjZlLTQ4YmEtOGIwZS1mYzI1YWYzNjBjN2YvNC9pbmRleF9maWxlcy9JbWFnZS5wbmc%3D.png?w=700&webp=1)
.tar.gz cd zabbix- ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent \ --with-mysql --with-net-snmp --with-libcurl make install
5、导入数据库(源码包的里面包含的数据库初始表,我这里没有给mysql设置密码,如果有密码,按有密码的导入)
mysql zabbix < database/mysql/schema.sql mysql zabbix < database/mysql/images.sql mysql zabbix < database/mysql/data.sql
6、修改配置文件
cp misc/init.d/fedora/core/zabbix_server /etc/init.d/ cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ cp -R frontends/php /var/www/html/zabbix sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/^.*DBPassword=.*$/DBPassword=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
7、添加服务端口:
cat >>/etc/services <<EOF zabbix-agent /tcp Zabbix Agent zabbix-agent /udp Zabbix Agent zabbix-trapper /tcp Zabbix Trapper zabbix-trapper /udp Zabbix Trapper EOF
8、启动服务
/etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start /etc/init.d/httpd start echo "/etc/init.d/zabbix_server start" >> /etc/rc.local echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.local
9、web页面配置,配置http访问好了后web登陆:
http://ip/zabbix. 主要会报一些php报错的信息,对应的修改就好了,date.timezone = Asia/Shanghai
![zabbix2.2部署安装(安装环境Centos 6.* X64) zabbix2.2部署安装(安装环境Centos 6.* X64)](https://image.shishitao.com:8440/aHR0cHM6Ly93d3cuc2h1emhpZHVvLmNvbS9Vc2Vycy9UaWFudGlhbmRhcy9Eb2N1bWVudHMvTXklMjBLbm93bGVkZ2UvdGVtcC80OGQ5OTBiNC0yZjZlLTQ4YmEtOGIwZS1mYzI1YWYzNjBjN2YvNC9pbmRleF9maWxlcy9mMTQ1MmM2NGI5YmU0MTUzZjRmYzYyZGM1NTJiMjRmZF85LnBuZw%3D%3D.png?w=700&webp=1)
最后还有可能说 /var/www/html/zabbix/conf/zabbix.conf.php文件的问题,这个需要把一个模板文件zabbix.conf.php.example拷贝为zabbix.conf.php,然后编辑这个php文件,主要是数据库连接的信息,核对正确即可。
初始登录账户和密码: admin zabbix
这个安装环境是6.5的系统,其实都一样。
10.最后我还做了如下几步操作
- 删除Apache的欢迎页面。位置: /etc/httpd/conf.d/welcome.conf,改为别的名称即可。
- 隐藏apache的版本信息。修改/etc/httpd/conf/httpd.conf. 修改项为:
- ServerTokens ProductOnly
- ServerSignature Off
- <Directory "/var/www/html">区域设定
- Options None
Order allow,deny
Allow from xx.xx.xx.xx(一般是自己公司的IP地址,只有这个IP可以访问zabbix的web,zabbix有安全漏洞,所以权限工作还是做好)完毕- 完毕!!