zabbxi中

nginx配置文件

worker_processes  1;

events {

        worker_connections  1024;

}


http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    error_log  /app/logs/nginx_error.log;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


         include  extra/zabbix.conf;

                                                                                                 


          }

zabbix配置文件

server {                                                                                                                                                     

listen       80;

server_name  localhost;

root   /app/html/zabbix;

index  index.php index.html index.htm;

access_log  /app/logs/zabbix_access.log main;

location ~ .*\.(php|php5)?$ {

    fastcgi_pass   127.0.0.1:9000;

    fastcgi_index  index.php;

    include        fastcgi.conf;

}


    }

1.1 安装lnp【必须有ngin,php,mysl

1.1.1 依赖包【已经按安装忽略】

yum install openldap openldap-devel  -y

yum install -y epel-release

yum install -y libmcrypt-devel

1.1.2 正常安装nginx

cp -a /usr/lib64/libldap* /usr/lib/

 

php初始化

./configure \

--prefix=/application/php-5.5.38 \

--enable-mysqlnd \

--with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--with-gettext \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-ldap \

--with-xsl \

--with-fpm-user=www \

--with-fpm-group=www \

--enable-opcache=no  \

--enable-ftp

1.2 修改php配置文件

vim  /application/php/lib/php.ini

egrep -n "^post_max_size|^max_execution_time|^max_input_time|^date.timezone" /application/php/lib/php.ini

372:max_execution_time = 300

382:max_input_time = 300

660:post_max_size = 16M

910:date.timezone = Asia/Shanghai

1.3 nginx主配置文件

vim /application/nginx/conf//nginx.conf

 

worker_processes  1;

events {

        worker_connections  1024;

}

 

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    error_log  /app/logs/nginx_error.log;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

 

         include  extra/zabbix.conf;

 

                                                                                                             

          }

1.3.1 配置文件分离【zabbix配置文件】

cat>/application/nginx/conf/extra/zabbix.conf <<'EOF'

server {

listen       80;

server_name  localhost;

root   /app/html;

index  index.php index.html index.htm;

access_log  /app/logs/zabbix/zabbix_access.log main;

location ~ .*\.(php|php5)?$ {

    fastcgi_pass   127.0.0.1:9000;

    fastcgi_index  index.php;

    include        fastcgi.conf;

}

 

    }

EOF

1.4 安装zabbix

1.4.1 下载编译包解压并进入解压目录

wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.17/zabbix-3.0.17.tar.gz

1.4.2 下载依赖包

yum install -y net-snmp net-snmp-devel fping unixODBC-devel openssl-devel OpenIPMI-devel java-devel mysql mysql-devel

1.4.3 创建虚拟用户

useradd zabbix -s /sbin/nologin -M

1.4.4 初始化【注意版本号

./configure \

--prefix=/application/zabbix-3.0.17 \

--enable-server \

--enable-agent \

--enable-java \

--with-mysql \

--enable-ipv6 \

--with-net-snmp \

--with-libcurl \

--with-libxml2 \

--with-openipmi \

--with-unixodbc \

--with-openssl

1.4.5 编译安装

make  make install

1.5 创建软链接

ln -s /application/zabbix-3.0.17/ /application/zabbix

1.6 创建zabbix数据库-zabbix用户并授权【数据库可以是本服务器也可以是其他】

create database zabbix character set utf8 collate utf8_bin;

grant all on zabbix.* to zabbix@'172.16.1.%' identified by 'zabbix';

flush privileges;

1.7 测试登陆数据库

mysql -h 172.16.1.51 -uzabbix -pzabbix

1.8 将数据导入数据库

cd /server/tools/zabbix-3.0.17/database/mysql/

mysql -h 172.16.1.51 -uzabbix -pzabbix zabbix < schema.sql

mysql -h 172.16.1.51 -uzabbix -pzabbix zabbix < images.sql

mysql -h 172.16.1.51 -uzabbix -pzabbix zabbix < data.sql

1.9 创建启动命令软链接

ln -s /application/zabbix/etc/ /etc/zabbix

ln -s /application/zabbix/bin/* /usr/bin/

ln -s /application/zabbix/sbin/* /usr/sbin/

1.10 拷贝启动脚本

cd /server/tools/zabbix-3.0.17/misc/init.d/fedora/core

cp zabbix_* /etc/init.d/

1.11 修改启动文件

sed  "s@BASEDIR=/usr/local@BASEDIR=/application/zabbix@g" /etc/init.d/zabbix_server -i

sed  "s@BASEDIR=/usr/local@BASEDIR=/application/zabbix@g" /etc/init.d/zabbix_agentd -i

1.12 修改zabbix服务端配置文件

vim /etc/zabbix/zabbix_server.conf

DBHost=172.16.1.51

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

1.13 复制zabbix站点到nginx站点目录

cp -a /server/tools/zabbix-3.0.17/frontends/php /app/html/zabbix

1.14 站点授权

chown -R www.www /app/html/zabbix

1.15 启动zabbix-agent

/etc/init.d/zabbix_server start

/etc/init.d/zabbix_agentd start

1.16 客户端yum安装zabbix

/etc/zabbix/zabbix_agentd.conf

Server=172.16.1.7         #zabbix-server IP地址

1.17 web访问zabbix

http://10.0.0.7/zabbix

用户名、密码

Admin

zabbix