{{ v.name }}
{{ v.cls }}类
{{ v.price }} ¥{{ v.price }}
1.前戏:
1.系统:ubuntu14.0或debian7.11
2.准备zabbix和lamp环境的安装源码包:(记住,对于一切安装包最稳妥的途径就是到相应官网上去下载,最好是lts长期支持的版本,否则,nozuonodie)
zabbix:zabbix-3.0.5.tar.gz
apache:httpd-2.4.23.tar.gz//apache官网
apr:apr-1.5.2.tar.gz//apache官网
apr-util:apr-util-1.5.4.tar.gz//apache官网
php:php-5.4.22.tar.gz
mysql:mysql-boost-5.7.12.tar.gz
boost:boost_1_59_0.tar.gz//5.7以后开始要求这个boost依赖,在此mysql-boost版本中含有链接,最好是根据里面的下载这种兼容性最好的版本
2.过程:
安装mysql5.7:
(具体参照前面的博客——关于lnmp编译安装的安装文档)
httpd(apache作为web):
配置:
./configure--prefix=/home/stt/server/apache
--enable-so
--enable-proxy--enable-cgi
--enable-info
--enable-rewrite
--enable-speling
--with-included-apr
--with-pcre
--enable-mods-shared=most
--enable-ssl
报错情况:
configure:error:bundledaprrequestedbutnotfoundat./srclib/.downloadandunpackthecorrespondingaprandapr-utilpackagesto./srclib/.
解决方案:
将apr和apr-util源码下载,解压放到httpd-2.4.23/srclib里面,并去除版本号
cp-rapr-1.5.2/httpd-2.4.23/srclib/apr
cp-rapr-util-1.5.4/httpd-2.4.23/srclib/apr-util
编译安装:
make&&makeinstall
php:
配置:
./configure--prefix=/home/stt/server/php
--with-apxs2=/home/stt/server/apache/bin/apxs
--with-config-file-path=/home/stt/server/php/etc
--with-mysql=/home/stt/server/mysql
--with-libxml-dir
--with-gd
--with-jpeg-dir
--with-png-dir
--with-freetype-dir
--with-iconv-dir
--with-zlib-dir
--with-bz2
--with-openssl
--with-mcrypt
--enable-soap
--enable-gd-native-ttf
--enable-mbstring
--enable-sockets
--enable-exif
--disable-ipv6
--enable-bcmath
--with-mysqli
--with-gettext
报错情况:
configure:error:cannotfindlibmysqlclient_runder
解决方案:
编译之前,先处理一下mysql的库,默认查找libmysqlclient_r.so,可是mysql默认为libmysqlclient.so,内容完全一样,做个链接即可
$cd/home/stt/server/mysql/lib
$ln-slibmysqlclient.so.20libmysqlclient_r.so
编译安装:
make&&makeinstall
安装zabbix:
配置:(根据官网的要求配置参数,当然,不一定一模一样,比如agent客户端就不必要)
./configure--prefix=/home/stt/server/zabbix
--enable-server
--enable-agent
--with-mysql=/home/stt/server/mysql/bin/mysql_config
--enable-ipv6
--with-net-snmp
--with-libcurl--with-libxml2
报错情况:
configure:error:notfoundnet-snmplibrary
解决方案:
apt-getinstall-ylibsnmp-devsnmp
安装:makeinstall
3.高潮:
修改配置文件:(关于lamp和zabbix的具体配置日后再在博客上持续发布,现在只谈环境的编译安装)
修改apache参数:
(重要配置部分)
在addtype字段处加入参数:
加入php可以作为首页:
(细节配置—可忽略)
listen8080//监听端口,因为1024以内的端口都是需要超级管理员root的权限去开启的,不修改就会在你启动apache服务的时候报错
serveradminyou@example.comservernamejavazabbix.java.com:8080
documentroot"/home/stt/server/apache/htdocs/zabbix"
修改php参数:
在gui上面有必要修改php参数vim/home/stt/server/php/etc/php.ini根据gui上面的提示修改max_input和timezone的参数,这是zabbi服务的要求。
php.ini配置文件修改:(根据zabbix官方文档对php的最低配置要求为准,否则在打开zabbixsetup页面就会有相应的红叉×)
max_execution_time=300
memory_limit=128m
post_max_size=16m
upload_max_filesize=2m
max_input_time=300
always_populate_raw_post_data=-1
date.timezone=asia/shanghai
测试lamp功能:
到这里基本的lamp+zabbix环境已经搭建完成,理论上是可以完成对php页面的支持。这里可以测试一下php能否和mysql通信
启动服务进行测试:
启动mysql
启动httpd(就是apache服务)
在页面放置的位置编写一个php能否连接mysql的测试页
cd/home/stt/server/apache/htdocs/;vimindex.php
$conn=mysql_connect('localhost','root','123456');
if($conn)
echo"connectmysqlsuccess......";
else
echo"failusr.....";
?>
(很明显,我是直接通过ip访问的,域名需要自己去绑定ip,在此不多扯)
配置mysql的zabbix用户权限:
mysql>createdatabasezabbixcharactersetutf8collateutf8_bin;
mysql>grantallprivilegesonzabbix.*tozabbix@localhostidentifiedby'
mysql>flushprivileges;
mysql>quit;
导入zabbix数据:(注意导入顺序,如果是package的,就不需要顾虑这点,因为三合一了)
cdzabbix-3.0.5/database/mysql
mysql-uzabbix-p mysql-uzabbix-p mysql-uzabbix-p 修改zabbix参数: vimzabbix_server.conf dbhost=localhost//注意下面我再讨论中发现的问题 dbname=zabbix dbuser=zabbix dbpassword=zabbix ############################## 讨论:为什么不用lnmp? 其实理论上是可以的,只是一直有道坎迈不过,就是zabbix对nginx的兼容性。当访问zabbixsetup页面的时候,总是会停留在第一步的页面,点击nextstep无反应。检查各服务的日志后会发现问题报错的唯有mysql上面,zabbix一直在报错[note]abortedconnection16830todb:'zabbix'user:'zabbix'host:'localhost'(gottimeoutreadingcommunicationpackets),问题显然出现在zabbix对mysql的连接上。但是当我进入mysql中查询连接数showfullprocesslist;的时候会发现,zabbix请求的进程已经连接到mysql中了,所以肯定不是连接不上数据库的问题。 经我查找,有友友这么解决:直接修改zabbix根目录下的conf/zabbix.conf.php.example: $db['type']='mysql';$db['server']='localhost';$db['port']='0';$db['database']='zabbix';$db['user']='zabbix';$db['password']='';//schemaname.usedforibmdb2andpostgresql.$db['schema']=''; $zbx_server='localhost';$zbx_server_port='10051';$zbx_server_name=''; $image_format_default=image_format_png; 解释: 复制一份zabbix.conf.php.example文件为zabbix.conf.php,因为zabbix.conf.php.example在web页面而设置后会生成zabbix.conf.php这样的页面,所以我们可以直接通过手动修改该配置页面,就可以直接访问zabbix的登录页了。但事实上,我并没有成功。我发现web页面会提示mysql失去连接。 现在谈到一个问题,当我在lamp中进行zabbix的web页面配置时发现,如果配置mysql的地址为localhost,则不能成功进入下一步设置,页面会提示mysql连接失败,但是我改为127.0.0.1就可以成功连接并完成zabbix的所有setup页面配置。由此我在这点联想到:在lnmp环境中手动修改配置文件不成功的原因是否也是如此。bytheway,肯定有人疑问:服务器中一文件/etc/hosts会解释localhost到127.0.0.1中,为毛使用locahost不行呢?并且,我在zabbix_server.conf配置dbmysql的地址是localhost,而在websetup页面中配置的dbmysql的地址在localhost和127.0.0.1中只有127.0.0.1正常连接,并且web页面中配置的和配置文件中添加的db地址不一样。这个问题嘛,我也的确没有去研究,希望能有人给我解答,毕竟我也是个小白。然而,我在此和大家说明一点,在mysql中,貌似由版本5.0开始,(有些版本)'%'不包括localhost,要单独对@'localhost'进行赋值。对用了%则代表了所有的host都能远程访问该mysql。 其中mysql官方文档有说明:%并不包括localhost,此处配置%远程其他host有权限访问,那么在mysql的配置文件中my.cnf,也需要做一些配置,将bind_address=0.0.0.0或者直接屏蔽掉此项。 当主机填写为localhost时mysql会采用unixdomainsocket连接 当主机填写为127.0.0.1时mysql会采用tcp方式连接