ZABBIX搭建
created by 薛峰
1、 这里的LAMP意思是:Linux + Apache + MySQL + PHP。
fontconfig-2.4.2.tar.gz;
二、搭建LAMP。
- ./configure \
- --prefix=/usr/local/mysql \
- --localstatedir=/usr/local/mysql/data \
- --without-debug \
- --without-docs \
- --without-geometry \
- --without-ndb-debug \
- --with-fast-mutexes \
- --with-embedded-server \
- --with-charset=latin1 \
- --with-extra-charsets=complex \
- --enable-thread-safe-client \
- --with-readline \
- --with-pthread \
- --enable-profiling \
- --enable-local-infile \
- --enable-assembler \
- --with-big-tables \
- --with-plugins=federated,innobase
(2)make && make install。
- useradd mysql /usr/local/mysql/bin/mysql_install_db --user=mysql &
- chgrp -R mysql *
- PATH=$PATH:/usr/local/mysql/bin
- source /etc/profile
- /usr/local/mysql/bin/mysqld_safe –user=mysql &
- /usr/local/mysql/bin/mysqladmin –uroot password ‘password’
- cp support-files/my-small.cnf /usr/local/mysql/etc/my.cnf
- cp –a /usr/local/mysql/data /home/mysql/
- /usr/local/mysql/bin/mysqld_safe \
- --defaults-file=/usr/local/mysql/etc/my.cnf \
- --datadir=/home/mysql/data --user=mysql &
- /usr/local/mysql/mysqladmin –uroot –p shutdown
- ./configure \
- --prefix=/usr/local/httpd \
- --enable-modules=most \
- --enable-mods-shared=all \
- --disable-info \
- --enable-so \
- --enable-rewrite \
- --enable-deflate
(2)make && make install
- DocumentRoot "/var/www"
(4)启动apache,在http://ipaddress看到”It works!”说明apache安装成功。
- /usr/local/httpd/bin/apachectl start
PHP中GD库很重要,要首先安装,而GD库又需要很多其他的包(见一3),按顺序安装,大多只需要”—prefix”一个参数即可,个别的另加参数。
(1) 按照顺序依次编译安装:
(2) 其中编译安装jpeg的时候,需要手动创建
(3) jpeg编译参数除了”--prefix”还有:
- --enable-shared --enable-static
(4) fontconfig的编译参数要添加:
- --with-freetype-config=/usr/local/freetype/bin/freetype-config
(5) 编译GD的参数:
- ./configure \
- --prefix=/usr/local/gd \
- --with-png=/usr/local/libpng \
- --with-freetype=/usr/local/freetype \
- --with-jpeg=/usr/local/jpeg \
- --with-fontconfig=/usr/local/fontconfig
- sh setupgd.sh | tee /root/gd.t
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: yes
Support for pthreads: yes
(7) 编译PHP。
- ./configure \
- --prefix=/usr/local/php \
- --with-config-file-path=/usr/local/php/etc \
- --with-mysql=/usr/local/mysql \
- --with-mysqli=/usr/local/mysql/bin/mysql_config \
- --enable-fpm \
- --enable-sockets \
- --enable-pdo \
- --with-pdo-mysql=/usr/local/mysql \
- --with-gd \
- --with-jpeg-dir=/usr/local/jpeg \
- --enable-bcmath \
- --enable-xml \
- --enable-mbstring \
- --with-zlib-dir=/usr/local/zlib \
- --with-png-dir=/usr/local/libpng \
- --with-freetype-dir=/usr/local/freetype \
- --with-apxs2=/usr/local/httpd/bin/apxs
(8) 编译完成之后,make && make install,由于每个人电脑环境有所差异,有的可能报错,google一下错误自行解决即可。
- Allow from all
(3)在标签” <IfModule dir_module>”之间附加”index.php”
(4)在"AddType application/x-gzip .gz .tgz"下添加一行:
- AddType application/x-httpd-php .php .phtml
- <?php
- phpinfo();
- ?>
三、搭建zabbix。
“Invalid NET-SNMP directory - unable to find net-snmp-config”
- ./configure \
- --prefix=/home/zabbix \
- --enable-server \
- --enable-proxy \
- --enable-agent \
- --with-mysql=/usr/local/mysql/bin/mysql_config \
- --with-net-snmp=/usr/local/snmp/bin/net-snmp-config \
- --with-libcurl
- useradd zabbix
- > create database zabbix character set utf8;
- > grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
- > mysql -uroot -p zabbix < create/schema/mysql.sql
- > mysql -uroot -p zabbix < create/data/data.sql
- > mysql -uroot -p zabbix < create/data/p_w_picpaths_mysql.sql
- zabbix-agent 10050/tcp Zabbix Agent
- zabbix-agent 10050/udp Zabbix Agent
- zabbix-Trapper 10051/tcp Zabbix Trapper
- zabbix-Trapper 10051/udp Zabbix Trapper
- mkdir /etc/zabbix
- cp misc/conf/zabbix_server.conf /etc/zabbix/
- cp misc/conf/zabbix_proxy.conf /etc/zabbix/
- cp misc/conf/zabbix_agent.conf /etc/zabbix/
- cp misc/conf/zabbix_agentd.conf /etc/zabbix/
- DBUser=zabbix
- DBPassword=zabbix
- cp misc/init.d/redhat/zabbix_server_ctl /etc/init.d/
- cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/
- BASEDIR=/home/zabbix,
- ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server
- cp -r frontends/php /var/htdoc/zabbix
zabbix_server: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
- echo /usr/local/mysql/lib/mysql/ >> /etc/ld.so.conf
- ldconfig
- /etc/init.d/zabbix_server_ctl start|stop|restart
- /etc/init.d/zabbix_agent_ctl start|stop|restart
13、ps –ef | grep zabbix相信可以看到输出结果。
“Timezone for PHP is not set. Please set "date.timezone" option in php.ini.”
3、 第三步是“Check of pre-requisites”页面,红色字体是需要修改的。通常是如图3的几项内容。
- > update mysql.user set host=’%’ where user=’zabbix’;
- > update mysql.db set host=’%’ where user=’zabbix’;
- > flush privileges;
转载于:https://blog.51cto.com/lsjing/952884