前言
之前的yum安装是方便。简单。但是呢,不方便升级。此处来个编译安装。
1.基础环境准备
[root@Aige ~]# cat /etc/redhat-release CentOS release 6.8 (Final) [root@Aige ~]# uname -r2.6.32-642.el6.x86_64[root@Aige ~]# /etc/init.d/iptables stop[root@Aige ~]# /etc/init.d/iptables stop[root@Aige ~]# chkconfig iptables off[root@Aige ~]# getenforce Disabled[root@Aige ~]# setenforce 0
2.快速搭建LNMP环境
需要自己定义rpm包,出门左拐就可以找到yum仓库的定制
安装依赖包
yum -y install pcre-devel openssl-devel ncurses-devel zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel libmcrypt-devel mhash mhash-devel mcrptrpm -ivh --aid *.rpm
3.安装zabbix
1.下载依赖包
yum -y install fping net-snmp-devel unixODBC-devel openssl-devel OpenIPMI-devel java-devel
2.添加用户
useradd zabbix -s /sbin/nologin
3.下载解压zabbix,并安装
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.8/zabbix-3.0.8.tar.gztar xf zabbix-3.0.8.tar.gz./configure --prefix=/application/zabbix-3.0.8 --enable-server --enable-agent --enable-java --enable-ipv6 --with-mysql=/application/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-opensslmake make installln -s /application/zabbix-3.0.8 /application/zabbix
报错:configure: error: Not found mysqlclient library
原因:通过二进制包安装mysql
解决:指定配置文件库
--with-mysql=/application/mysql/bin/mysql_config
或者yum install mysql-devel -y
4.导入数据库
进入mysql创建库和用户
[mysql]:create database zabbix character set utf8 collate utf8_bin; [mysql]:grant all on zabbix.* to zabbix@'127.0.0.1' identified by 'zabbix'; [mysql]:flush privileges;
导入数据,必须依次导入
schema.sql # 表结构,首先导入
p_w_picpaths.sql # 图形,第二
data.sql # 数据,最后导入
三个文件在源码解压的database/mysql下面
cd /root/zabbix-3.0.8/database/mysql/
[mysql]: use zabbix [mysql]: source /root/zabbix-3.0.8/database/mysql/schema.sql [mysql]: source /root/zabbix-3.0.8/database/mysql/p_w_picpaths.sql [mysql]: source /root/zabbix-3.0.8/database/mysql/data.sql
5.修改nginx配置文件
源码包里的站点配置文件。
mkdir -p /application/nginx/html/zabbixcp -a /root/zabbix-3.0.8cp -a /root/zabbix-3.0.8/frontends/php/* /application/nginx/html/zabbix/ # 站点目录chown -R www /application/nginx/html/zabbix/ # 授权用户
6.配置zabbix
6.1 php配置
sed -i 's#max_execution_time = 30#max_execution_time = 300#;s#max_input_time = 60#max_input_time = 300#;s#post_max_size = 8M#post_max_size = 16M#;910a date.timezone = Asia/Shanghai' /application/php/lib/php.ini
6.2zabbix服务配置
sed -i -e '77a DBHost=127.0.0.1' -e '111a DBPassword=zabbix' # 修改mysql服务位置和mysql密码 /application/zabbix/etc/zabbix_server.confcp /root/zabbix-3.0.8/misc/init.d/fedora/core/zabbix_{server,agentd} /etc/init.d/ # 拷贝启动文件sed -i 's#BASEDIR=/usr/local#BASEDIR=/application/zabbix#g' /etc/init.d/zabbix_{server,agentd} # 修改启动目录
6.3启动脚本
启动报错
[root@Aige ~]# /etc/init.d/zabbix_server startStarting zabbix_server: /application/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory [FAILED]
解决
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
浏览器测试
http://10.0.0.110/zabbix
报错:需要进入源码包
界面只有一个,没有mysql
PHP databases support SQLite3 OK
原因:二进制编译安装的PHP安装出现了问题,mysqli没有安装
cd /root/php-5.5.32/extcd /root/php-5.5.32/ext/mysqli//application/php/bin/phpize./configure --with-php-config=/application/php/bin/php-configmake && make installecho "extension = mysqli.so" >> /application/php/lib/php.ini /application/php/bin/php -m| grep mysqlpkill php/application/php/sbin/php-fpm
PHP gettext on warning
原因:缺少一个模块:该模块支持中文模式
解决:到源码包里的
cd /root/php-5.5.32/extcd gettext/ # 动态扩容,phpize必须到目录下才能执行/application/php/bin/phpize./configure --with-php-config=/application/php/bin/php-config # 再次编译make && make installecho "extension = gettext.so " >> /application/php/lib/php.inipkill php-fpm # 重启生效/application/php/sbin/php-fpm/application/php/bin/php -m # 查看编译参数(模块)
解决过程
[root@Aige ext]# cd gettext/[root@Aige gettext]# lsconfig.m4 config.w32 CREDITS gettext.c gettext.dsp gettext.lo gettext.o php_gettext.h tests [root@Aige gettext]# /application/php/bin/phpize Configuring for:PHP Api Version: 20121113Zend Module Api No: 20121212Zend Extension Api No: 220121212