zabbix 安装

php+nginx+mysql+zabbix

官方https://www.zabbix.com/documentation/3.0/manual/installation/install

1、安装依赖包

yum install -y gcc gcc-c++ gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel libmcrypt libmcrypt-devel

 

2、安装php

mkdir -p /usr/local/php5  #建立php安装目录  

tar -xvf php-5.6.24.tar.gz

cd php-5.6.24

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql --with-mysqli=/usr/lib64/mysql/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir --with-freetype-dir

make

make test

make install

 

  • PHP系统配置文件设置

 

cp  php.ini-production   /usr/local/php5/etc/php.ini

rm -rf /etc/php.ini  # 删除系统自带配置文件

ln -s /usr/local/php5/etc/php.ini  /etc/php.ini    #添加软链接 

cd /usr/local/php5/etc

cp php-fpm.conf.default php-fpm.conf

vim  /usr/local/php5/etc/php-fpm.conf

pid = run/php-fpm.pid    #取消前面的分号

  • PHP开机启动设置

cd /home/software/php-5.6.24/sapi/fpm

cp init.d.php-fpm  /etc/init.d/php-fpm  #设置 php-fpm开机启动,拷贝php-fpm到启动目录   

chmod +x /etc/init.d/php-fpm  #添加执行权限

chkconfig php-fpm on  #设置开机启动 

  • PHP配置文件设置

vim /etc/php.ini
date.timezone =Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M
;mbstring.func_overload = 2      //需要注销使用;号

启动/usr/local/php5/sbin/php-fpm

 

 

3、配置mysql

参考http://www.cnblogs.com/shhnwangjian/p/5522505.html

 

4、新增用户

groupadd zabbix

useradd zabbix -g zabbix -s /sbin/nologin

 

5、安装zabbix

tar -xvf zabbix-3.0.4.tar.gz

cd zabbix-3.0.4

./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ssh2 --enable-java

make

make install

 

6、导入数据

mysql -u root -p

输入密码

CREATE DATABASE IF NOT EXISTS zabbix DEFAULT CHARSET utf8 COLLATE utf8_general_ci;       //创建zabbix数据库,并设置字符集为utf8

grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';  //创建zabbix帐号并赋权,密码为zabbix

flush privileges;

exit退出

 

通过zabbix账号登陆mysql -u zabbix -p

输入密码

source /home/software/zabbix-3.0.4/database/mysql/schema.sql;   //proxy服务器的话只需要导入这个即可

source /home/software/zabbix-3.0.4/database/mysql/images.sql;

source /home/software/zabbix-3.0.4/database/mysql/data.sql;

show tables; //查看导入的表

 

7、zabbix启动脚本

cp /home/software/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_* /etc/init.d/        //添加服务

chmod 755 /etc/init.d/zabbix_*

vim /etc/init.d/zabbix_server   //将BASEDIR修改为安装路径

vim /etc/init.d/zabbix_agentd将BASEDIR修改为安装路径

 

8、修改/etc/zabbix/zabbix_server.conf

vim /etc/zabbix/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBPort=3306
DBName=zabbix                            //zabbix所属数据库名称
DBUser=zabbix                            //zabbix所属数据库用户
DBPassword=zabbix                        //zabbix数据库密码
DBSocket=/var/lib/mysql/mysql.sock
StartPollers=500                         //轮询的初始值(0-1000)
StartIPMIPollers=10                       //IPMI轮询的初始值(0-1000)
StartPollersUnreachable=150               //轮询不可达的主机数(包括IPMI 0-1000)
StartTrappers=20                         //捕获的初始值(0-1000)
StartPingers=10                          //ping的初始值(0-1000)
StartDiscoverers=5                      //自动发现的初始值(0-250)
CacheSize=256M                          //缓存大小
CacheUpdateFrequency=300                //缓存更新的频率
StartDBSyncers=8                        //数据库同步时间
TrendCacheSize=128M                     //总趋势缓存大小
AlertScriptsPath=/home/zabbix/alertscripts               //脚本的存放位置
LogSlowQueries=3000                     //日志慢查询设定


9、nginx配置

nginx安装参考http://www.cnblogs.com/shhnwangjian/p/5719044.html

cp -rf /home/software/zabbix-3.0.4/frontends/php/* /usr/local/nginx/html/zabbix/

/usr/local/nginx/conf下创建extra目录

/usr/local/nginx/conf/extra创建zabbix.conf

 

server {
    listen       80;
    server_name  localhost;
    root   /usr/local/nginx/html;
    index  index.php index.html index.htm;
    access_log  logs/zabbix_access.log;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   html;
    }
    location ~ \.(php|php5)?$ {
      root           /usr/local/nginx/html;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
      include        fastcgi_params;
    }
}

 在nginx.conf文件中的http下加入

include  extra/zabbix.conf;

 重启nginx

 

10、访问zabbix web页面

http://10.10.83.162/zabbix/

 

如检测不到配置文件,下载zabbix.conf.php文件,放到提示路径下,刷新页面

初始登陆账号Admin,密码zabbix

 

FAQ:

 

解决方法:vim /usr/local/nginx/html/zabbix/include/classes/setup/CFrontendSetup.php

        public function checkPhpAlwaysPopulateRawPostData() {
                $current = ini_get('always_populate_raw_post_data');

                $current = -1;   # 需要添加
                return [
                        'name' => _s('PHP option "%1$s"', 'always_populate_raw_post_data'),
                        'current' => ($current != -1) ? _('on') : _('off'),
                        'required' => _('off'),
                        'result' => ($current != -1) ? self::CHECK_FATAL : self::CHECK_OK,
                        'error' => _s('PHP option "%1$s" must be set to "%2$s"', 'always_populate_raw_post_data', -1)
                ];
        }

 

posted @ 2016-08-05 10:55  shhnwangjian  阅读(426)  评论(0编辑  收藏  举报