博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
源码编译LNMP+最新版zabbix4.0
阅读量:6213 次
发布时间:2019-06-21

本文共 10876 字,大约阅读时间需要 36 分钟。

LNMP+Zabbix4.0

之前发过一篇LAMP中的zabbix,兴趣使然,研究一下LNMP中源码编译zabbix的搭建。话不多说,直接上环境及操作步骤。

系统 IP 软件列表
centos7 192.168.70.136 nginx1.8/mysql5.7/php7.3/zabbix4.0

zabbix4.0下载地址

其他软件包可以在我博客上找:

一、nginx安装

1、安装基础环境

[root@localhost opt]# yum -y install gcc gcc-c++ autoconf gd-devel automake zlib zlib-devel openssl openssl-devel pcre*

2、解压编译

[root@localhost opt]# tar zxf nginx-1.8.1.tar.gz

[root@localhost opt]# cd nginx-1.8.1/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_stub_status_module

3、安装

[root@localhost nginx-1.8.1]# make && make install

4、创建nginx用户,检查配置文件

[root@localhost nginx-1.8.1]# useradd -M -s /sbin/nologin nginx

[root@localhost nginx-1.8.1]# ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
[root@localhost nginx-1.8.1]# nginx -t #配置文件没问题,如下
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

二、mysql解压版安装

1、解压mysql并更名

[root@localhost opt]# tar zxf mysql-5.7.21-linux-glibc2.12-x86_64.tgz

[root@localhost opt]# mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql

2、修改配置文件

[root@localhost opt]# vim /etc/my.cnf #删除原有的内容,添加如下

[client]port = 3306socket = /tmp/mysql.sock[mysqld]character-set-server = utf8mb4skip_name_resolve = 1user = mysqlport = 3306socket = /tmp/mysql.sockbasedir = /opt/mysql/datadir = /opt/mysql/datalog-error = /opt/mysql/data/log-error.logpid-file = /opt/mysql/data/mysql.pidinnodb_data_home_dir = /opt/mysql/dataslow-query-log-file=/opt/mysql/data/slow.logrelay-log-index = /opt/mysql/data/relaylogrelay-log-info-file = /opt/mysql/data/relaylogrelay-log = /opt/mysql/data/relaylogopen_files_limit = 10240table_open_cache = 2048back_log = 300max_connections = 10000max_connect_errors = 20explicit_defaults_for_timestamp = 1max_allowed_packet = 64Mthread_cache_size = 300query_cache_size = 256Mquery_cache_limit = 2Mquery_cache_min_res_unit = 2kdefault-storage-engine = InnoDBthread_stack = 512Ktransaction_isolation = READ-COMMITTEDtmp_table_size = 256Mmax_heap_table_size = 256Mkey_buffer_size = 2Gsort_buffer_size = 2Mjoin_buffer_size = 6Mread_buffer_size = 4Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 15Gmyisam_repair_threads = 1interactive_timeout = 1800wait_timeout = 28800innodb_data_file_path = ibdata1:120M;ibdata2:200M;ibdata3:200M:autoextendinnodb_buffer_pool_size = 2Ginnodb_thread_concurrency = 0innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 16Minnodb_log_file_size = 512Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_purge_threads = 0slow_query_log = 1long_query_time = 3replicate-ignore-db = mysqlreplicate-ignore-db = testreplicate-ignore-db = information_schema#slave-skip-errors = 1032,1062,1026,1114,1146,1048,1396server-id = 1sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION[mysqldump]quickmax_allowed_packet = 64M

3、创建mysql用户,并初始化

[root@localhost opt]# adduser -s /sbin/nologin mysql

[root@localhost opt]# ln -s /opt/mysql/bin/* /usr/bin/
[root@localhost opt]# mysqld --initalize-insecure --user=mysql

4、启动,设置数据库密码

[root@localhost mysql]# mysqld_safe &

[root@localhost opt]# mysqladmin -uroot password '123123'
[root@localhost opt]# mysql -uroot -p #使用密码登陆

三、安装PHP7.3

1、安装基础环境

yum -y install pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel openldap-servers openldap-client nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel bzip2 bzip2-devel libxml2 libxml2-devel bzip2 bzip2-devel curl-devel  gmp-devel readline-devel libxslt-devel

2、解压php压缩包

[root@localhost opt]# tar zxf php-7.3.1.tar.gz

3、解决编译及小问题

●configure:?error:?off_t undefined; check your library configuration    解决方法    echo '/usr/local/lib64    /usr/local/lib    /usr/lib    /usr/lib64'>>/etc/ld.so.conf&&ldconfig -v●configure: error: Please reinstall the libzip distribution    解决方法    wget https://nih.at/libzip/libzip-1.2.0.tar.gz    tar -zxvf libzip-1.2.0.tar.gz    cd libzip-1.2.0    ./configure    make    make install●/usr/local/include/zip.h:59:21: 致命错误:zipconf.h:没有那个文件或目录    解决方法    cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

4、编译

[root@localhost opt]# cd php-7.3.1/

./configure \
--prefix=/usr/local/php7 \
--with-pdo-mysql=/opt/mysql \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
-with-mysqli=mysqlnd \
--with-mysql-sock=/tmp/mysql.sock \
--with-config-file-path=/usr/local/php7 \
--enable-fpm \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-onig \
--enable-pdo \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--with-pear \
--enable-opcache

5、安装

[root@localhost php-7.3.1]# make && make install

6、复制配置文件,创建命令软链接

[root@localhost php-7.3.1]# cp php.ini-development /usr/local/php7/php.ini

[root@localhost php-7.3.1]# ln -s /usr/local/php7/bin/ /usr/local/bin/
[root@localhost php-7.3.1]# ln -s /usr/local/php7/sbin/
/usr/local/sbin/

7、创建php用户

[root@localhost php-7.3.1]# useradd -M -s /sbin/nologin php

8、修改配置文件格式及配置文件

[root@localhost php-7.3.1]# cd /usr/local/php7/etc/php-fpm.d

[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# vim www.conf

#修改以下内容user = phpgroup = phppm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35

#该文件也需要改格式

[root@localhost php-fpm.d]# cd /usr/local/php7/etc/

[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf

9、启动php,查看进程

[root@localhost etc]# php-fpm

[root@localhost etc]# pgrep php
100537
100538
100539
..........
...........

10、修改nginx配置文件,nginx连接php

[root@localhost etc]# vim /usr/local/nginx/conf/nginx.conf

location ~ \.php$ {            root           html;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        #这里一定要改成绝对路径或者$document_root,否则会返回空白页面            include        fastcgi_params;        }

11、修改首页,测试连接php

[root@localhost etc]# vim /usr/local/nginx/html/index.php

12、启动nginx,网页访问测试

记得找mysqli和mysqlnd两个参数
源码编译LNMP+最新版zabbix4.0

四、安装zabbix4.0

1、安装基础环境

[root@localhost etc]# yum install net-snmp net-snmp-devel fping unixODBC-devel openssl-devel OpenIPMI-devel libevent libevent-devel pcre-devel -y

2、创建zabbix用户

[root@localhost etc]# useradd zabbix -s /sbin/nologin

3、解压,编译

[root@localhost etc]# cd /opt/

[root@localhost opt]# tar zxf zabbix-4.0.4.tar.gz
./configure \
--prefix=/usr/local/zabbix \
--enable-server \
--enable-agent \
--with-mysql \
--enable-ipv6 \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--with-openipmi \
--with-unixodbc \
--with-openssl \
--with-gettext

4、安装

[root@localhost zabbix-4.0.4]# make && make install

5、改zabbix目录权限

[root@localhost zabbix-4.0.4]# cd /usr/local && chown -R zabbix:zabbix zabbix

6、创建zabbix数据库,倒sql语句

[root@localhost local]# mysql -uroot -p

#sql语句文件在解压过的zabbix目录当中    mysql> create database if not exists zabbix default character set utf8 collate utf8_general_ci;    mysql> use zabbix;    mysql> source /opt/zabbix-4.0.4/database/mysql/schema.sql    mysql> source /opt/zabbix-4.0.4/database/mysql/images.sql    mysql> source /opt/zabbix-4.0.4/database/mysql/data.sql

7、创建日志文件

[root@localhost local] cd /usr/local/zabbix

[root@localhost zabbix]# mkdir logs
[root@localhost zabbix]# chown zabbix:zabbix logs

8、修改zabbix_server.conf文件

[root@localhost zabbix]# cd /usr/local/zabbix/etc/

LogFile=/usr/local/zabbix/logs/zabbix_server.logPidFile=/tmp/zabbix_server.pidDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=123123DBSocket=/tmp/mysql.sockInclude=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf

9、修改zabbix_agentd.conf

[root@localhost etc]# vim zabbix_agentd.conf

PidFile=/tmp/zabbix_agentd.pidLogFile=/usr/local/zabbix/logs/zabbix_agentd.logInclude=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf

10、启动服务

[root@localhost etc]# /usr/local/zabbix/sbin/zabbix_server

[root@localhost etc]# /usr/local/zabbix/sbin/zabbix_agentd

如果报错:/usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory解决方法:[root@localhost etc]# ln -s /opt/mysql/lib/libmysqlclient.so.20 /usr/lib/[root@localhost etc]# ldconfig 如果启动后看不到zabbix10050的进程号,日志文件中会有提示,不能连接数据库这时候去数据库给zabbix用授权即可mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '123123';

11、修改nginx配置文件,指定zabbix安装目录

[root@localhost logs]# cd /usr/local/nginx/conf/

[root@localhost conf]# vim nginx.conf

location / {            root   /usr/local/nginx/html/data/zabbix;            index  index.html index.htm;        }        location ~ \.php$ {            root           /usr/local/nginx/html/data/zabbix;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/data/zabbix$fastcgi_script_name;            include        fastcgi_params;        }

[root@localhost conf]# cd /usr/local/nginx/html/

[root@localhost html]# mdkir data
[root@localhost html]# mv /opt/zabbix-4.0.4/frontends/php/ data/zabbix
[root@localhost html]# chmod 777 -R data/

12、重启nginx,网页安装

192.168.70.136/index.php

[root@localhost html]# nginx -s reload

源码编译LNMP+最新版zabbix4.0

源码编译LNMP+最新版zabbix4.0
这里fail,去修改php.ini配置文件,按照它提示的字段

[root@localhost html]# cd /usr/local/php7/[root@localhost php7]# vim php.ini post_max_size = 16Mmax_execution_time = 300date.timezone = Asia/Shanghai然后重启php[root@localhost php7]# killall php-fpm[root@localhost php7]# php-fpm

源码编译LNMP+最新版zabbix4.0

源码编译LNMP+最新版zabbix4.0
源码编译LNMP+最新版zabbix4.0
源码编译LNMP+最新版zabbix4.0
源码编译LNMP+最新版zabbix4.0
源码编译LNMP+最新版zabbix4.0
源码编译LNMP+最新版zabbix4.0
源码编译LNMP+最新版zabbix4.0

到这里LNMP的zabbix安装就结束了,之前忙,没有去写zabbix监控的相关使用,下篇博客为大家介绍zabbix相关监控的使用~

转载于:https://blog.51cto.com/13760226/2348852

你可能感兴趣的文章
ng 核心模块
查看>>
java web 获取到当前用户请求的完整url,包括参数
查看>>
Sublime Text 3 快捷键精华版
查看>>
Android异步消息机制
查看>>
iOS 来点不一样的推送 - 语音提示
查看>>
香蕉派 banana pi BPI-M1+ 单板计算机,板载WIFI
查看>>
深度拷贝
查看>>
git笔记
查看>>
Android 跳转到各系统页面
查看>>
Android Studio 实用快捷键
查看>>
使用ajax用户名密码登录后转发至WEB-INF下的方法
查看>>
JVM类加载机制详解(一)JVM类加载过程
查看>>
解决 Hudson 控制台输出乱码
查看>>
linux的文件操作
查看>>
centos systemctl 配置详解
查看>>
Git中三种文件状态及其转换
查看>>
规格模式取代sql查询代码
查看>>
javascript引用动态变量名的变量值
查看>>
实现struts2零配置流程
查看>>
用maven+springMVC创建一个项目 【转】
查看>>