zabbix运行在lamp环境或者lnmp环境都是可以的,如果是新系统推荐使用lamp或者lnmp一键安装包,
或者可以向下面这种方式:
PHP安装
源码安装
rpm -ivh php55w-common-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-cli-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-5.5.38-1.w6.x86_64.rpm; rpm -ivh t1lib-5.1.2-6.el6_2.1.x86_64.rpm; rpm -ivh php55w-gd-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-pdo-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-mysql-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-bcmath-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-mbstring-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-xml-5.5.38-1.w6.x86_64.rpm; rpm -ivh php55w-ldap-5.5.30-1.w6.x86_64.rpm;
PS:遇到的问题,安装第三个php rpm包时,提示:
没有安装httpd-mmn = 20051115
[[email protected] zabbix_file]# rpm -ivh php55w-5.5.38-1.w6.x86_64.rpm warning: php55w-5.5.38-1.w6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY error: Failed dependencies: httpd-mmn = 20051115 is needed by php55w-5.5.38-1.w6.x86_64 httpd is needed by php55w-5.5.38-1.w6.x86_64 [[email protected]-server zabbix_file]#
这里需要安装httpd服务,但安装httpd时,提示:
[[email protected] zabbix_file]# rpm -ivh httpd-2.2.15-60.el6.centos.4.x86_64.rpm error: Failed dependencies: apr-util-ldap is needed by httpd-2.2.15-60.el6.centos.4.x86_64 httpd-tools = 2.2.15-60.el6.centos.4 is needed by httpd-2.2.15-60.el6.centos.4.x86_64 libapr-1.so.0()(64bit) is needed by httpd-2.2.15-60.el6.centos.4.x86_64 libaprutil-1.so.0()(64bit) is needed by httpd-2.2.15-60.el6.centos.4.x86_64
因为机器不能访问外网,我只上传了个iso镜像上去做本地yum源,也许改用源码的方式安装httpd会靠谱些,但编译时提示:
configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" setting CFLAGS to " -g -O2 -pthread" setting CPPFLAGS to " -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE" setting LDFLAGS to " " configure: configure: Configuring Apache Portable Runtime Utility library... configure: checking for APR-util... no configure: error: APR-util not found. Please read the documentation.
还是绕不过上面的那个坎,apr-util
我参考了这篇博客:http://www.linuxidc.com/Linux/2012-06/62289.htm
今日编译apache时出错: #./configure --prefix……检查编辑环境时出现: checking for APR... no configure: error: APR not found . Please read the documentation 解决办法: 1.下载所需软件包: wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip 2.编译安装: yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs 具体步骤如下: a:解决apr not found问题>>>>>> [[email protected] test]# tar -zxf apr-1.4.5.tar.gz [[email protected] test]# cd apr-1.4.5 [[email protected] apr-1.4.5]# ./configure --prefix=/usr/local/apr [[email protected] apr-1.4.5]# make && make install b:解决APR-util not found问题>>>> [[email protected] test]# tar -zxf apr-util-1.3.12.tar.gz [[email protected] test]# cd apr-util-1.3.12 [[email protected] apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config [[email protected] apr-util-1.3.12]# make && make install c:解决pcre问题>>>>>>>>> [[email protected] test]#unzip -o pcre-8.10.zip [[email protected] test]#cd pcre-8.10 [[email protected] pcre-8.10]#./configure --prefix=/usr/local/pcre [[email protected] pcre-8.10]#make && make install 4.最后编译Apache时加上: --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre 成功编译完成~
不过安装apr和apr-util之前又遇到个坑:
编译apr时出现这个报错:configure: error: no acceptable C compiler found in $PATH
原因是系统没安装gcc软件套件,还好这个本地yum有(终于起作用了,好感动),直接yum install gcc就行。
安装pcre时又遇到坑:这次提示g++ 在make pcre的时候出现libtool: line 990: g++: command not found错误 解决方法:yum -y install gcc+ gcc-c++,都装了。
继续make pcre又报错:.libs/pcrecpp.o: could not read symbols: Bad value 解决方法:./configure --disable-shared --with-pic 编译时多加个参数
好了,继续源码安装apache
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre make && make install
嗯,安装完php,继续!
PS:发现一件尴尬的事情,apr相关的包,在本地yum源里有。。
配置PHP参数:
[[email protected] zabbix_file]# sed -i "[email protected];date.timezone [email protected] = Asia/[email protected]" /etc/php.ini [[email protected] zabbix_file]# sed -i "[email protected]_execution_time = [email protected]_execution_time = [email protected]" /etc/php.ini [[email protected] zabbix_file]# sed -i "[email protected]_max_size = [email protected]_max_size = [email protected]" /etc/php.ini [[email protected] zabbix_file]# sed -i "[email protected]_input_time = [email protected]_input_time = [email protected]" /etc/php.ini [[email protected] zabbix_file]# sed -i "[email protected]_limit = [email protected]_limit = [email protected]" /etc/php.ini [[email protected] zabbix_file]# sed -i "[email protected];mbstring.func_overload = [email protected]_overload = [email protected]" /etc/php.ini [[email protected] zabbix_file]# sed -i "[email protected];always_populate_raw_post_data [email protected]_populate_raw_post_data = [email protected]" /etc/php.ini
接着安装mysql,要查看是否已安装mysql,如果版本不符合,则需要卸载,重装:
[[email protected] zabbix_file]# rpm -qa| grep mysql mysql-5.1.71-1.el6.x86_64 mysql-server-5.1.71-1.el6.x86_64 php55w-mysql-5.5.38-1.w6.x86_64 qt-mysql-4.6.2-26.el6_4.x86_64 mysql-libs-5.1.71-1.el6.x86_64 强制卸载: [[email protected] zabbix_file]# rpm -e --nodeps mysql-5.1.71-1.el6.x86_64 [[email protected] zabbix_file]# rpm -e --nodeps mysql-server-5.1.71-1.el6.x86_64 warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave [[email protected] zabbix_file]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
下载mysql5.5tar包并解压:
[[email protected] zabbix_file]# tar -xvf MySQL-5.5.56-1.el6.x86_64.rpm-bundle.tar MySQL-shared-5.5.56-1.el6.x86_64.rpm tar: MySQL-shared-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:41 is 15825714.217439403 s in the future MySQL-test-5.5.56-1.el6.x86_64.rpm tar: MySQL-test-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:45 is 15825717.725779682 s in the future MySQL-server-5.5.56-1.el6.x86_64.rpm tar: MySQL-server-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:31 is 15825702.522847995 s in the future MySQL-embedded-5.5.56-1.el6.x86_64.rpm tar: MySQL-embedded-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:10 is 15825680.34405559 s in the future MySQL-client-5.5.56-1.el6.x86_64.rpm tar: MySQL-client-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:02 is 15825671.899264437 s in the future MySQL-devel-5.5.56-1.el6.x86_64.rpm tar: MySQL-devel-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:07 is 15825676.822329417 s in the future MySQL-shared-compat-5.5.56-1.el6.x86_64.rpm tar: MySQL-shared-compat-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:42 is 15825711.705837133 s in the future [[email protected] zabbix_file]# ls MySQL-5.5.56-1.el6.x86_64.rpm-bundle.tar MySQL-test-5.5.56-1.el6.x86_64.rpm php55w-mysql-5.5.38-1.w6.x86_64.rpm MySQL-client-5.5.56-1.el6.x86_64.rpm php55w-5.5.38-1.w6.x86_64.rpm php55w-pdo-5.5.38-1.w6.x86_64.rpm MySQL-devel-5.5.56-1.el6.x86_64.rpm php55w-bcmath-5.5.38-1.w6.x86_64.rpm php55w-xml-5.5.38-1.w6.x86_64.rpm MySQL-embedded-5.5.56-1.el6.x86_64.rpm php55w-cli-5.5.38-1.w6.x86_64.rpm php-ldap-5.5.29-1.mga4.x86_64.rpm MySQL-server-5.5.56-1.el6.x86_64.rpm php55w-common-5.5.38-1.w6.x86_64.rpm t1lib-5.1.2-6.el6_2.1.x86_64.rpm MySQL-shared-5.5.56-1.el6.x86_64.rpm php55w-gd-5.5.38-1.w6.x86_64.rpm MySQL-shared-compat-5.5.56-1.el6.x86_64.rpm php55w-mbstring-5.5.38-1.w6.x86_64.rpm
共八个rpm包,暂时只需要用到server和client:
[[email protected] zabbix_file]# rpm -ivh MySQL-server-5.5.56-1.el6.x86_64.rpm warning: MySQL-server-5.5.56-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:MySQL-server ########################################### [100%] [[email protected] zabbix_file]# rpm -ivh MySQL-client-5.5.56-1.el6.x86_64.rpm warning: MySQL-client-5.5.56-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]
不过我把所有mysql rpm包都装了顺序是:
rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-devel-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-embedded-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm rpm -ivh mysql-community-test-5.7.11-1.el6.x86_64.rpm
查看mysql安装路径:
[[email protected] zabbix_file]# find / -name mysql -print /etc/rc.d/init.d/mysql /etc/logrotate.d/mysql /usr/lib64/perl5/DBD/mysql /usr/lib64/perl5/auto/DBD/mysql /usr/lib64/mysql /usr/share/mysql /usr/bin/mysql /var/lib/mysql /var/lib/mysql/mysql data默认目录:/var/lib/mysql mysql默认安装目录:/usr/share/mysql
PS:在mysql5.5 的安装目录里会有多个cnf配置文件,根据需要复制一个到/etc/my.cnf。mysql5.5之后的就默认只有一个配置文件了/etc/my.cnf(linux版本)
设置账号、密码、字符编码:
刚刚安装的mysql不输入密码也可以进入mysql交互界面,重置root有多种方法,这里介绍其中一种:
在my.cnf的[mysqld]下面加一行:skip-grant-tables
然后重启mysql,再进入交互界面重置密码,最后再删了skip-grant-tables
[[email protected] mysql]# vim /etc/my.cnf [[email protected] mysql]# service mysql restart Shutting down MySQL. [ OK ] Starting MySQL... [ OK ] [[email protected] mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.56-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> UPDATE user SET password=PASSWORD("zabbix_server") WHERE user=‘root‘; ERROR 1046 (3D000): No database selected mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> use mysql; Database changed mysql> UPDATE user SET password=PASSWORD("zabbix_server") WHERE user=‘root‘; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec)
如果安装lnmp没问题,接下来就是安装zabbix装。https://www.zabbix.com/documentation/2.4/manual/installation/install
这个是官网上面的教程选择“4 Installation from sources”这个选项,意思就是源文件安装。
1.先解压源文件:$tar -zxvf zabbix-2.4.7.tar.gz
2.在/database/mysql文件夹下找到schema.sql、images.sql、data.sql这三个文件
3.创建mysql账号
mysql -u root -p
mysql> create user ‘zabbix‘@‘localhost‘ identified by ‘zabbix‘;
mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to ‘zabbix‘@‘localhost‘;
mysql> flush privileges;
mysql> exit;
4.导入初始化数据
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
这样Zabbix的初始数据就导入了。
5.然后:groupadd zabbix
useradd -g zabbix zabbix
6.Configure the sources
./configure --prefix=/usr/local --enable-server --enable-agent --with-mysql
--enable-ipv6 --with-libcurl --with-libxml2 --with-net-snmp
configure后面的 --prefix=/usr/local最好是加上,加上之后后面一步的make install就能安装到这
个/usr/local/文件夹下了。
最后的 --with-net-snmp加了会报错,不加之后就好了。(当然,net-snmp这个最好安装一下,目前还
不知道不加这个有没有什么问题,暂时没有发现影响)
PS:我用lnmp一键安装包部署的环境,mysql不在默认路径下,我需要把--with-mysql 改成:--with-mysql=/usr/local/mysql/bin/mysql_config 可以通过find / -name mysql_config搜到具体路径
在编译的过程中,会需要说某某rpm包找不到,这时可以通过yum安装。
yum -y install gcc+ gcc-c++
原文地址:https://www.cnblogs.com/laonicc/p/7290110.html