操作系统:Centos6.8
环境要求:Nginx-1.10.2 MySql-5.5.48 php-5.4.45(PHP版本必须大于等于5.4)
环境安装包下载:
# wget http://soft.ileiming.com/soft1.1.tar.gz
YUM准备:
# yum -y install 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 bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
编译安装环境:
# tar -zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure --prefix=/usr/local
# make && make install
# tar -zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure
# make && make install
# /sbin/ldconfig
# cd libltdl/
# ./configure --enable-ltdl-install
# make && make install
# tar -zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9
# ./configure
# make && make install
# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
# ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
# /sbin/ldconfig
# tar -zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# ./configure
# make && make install
# tar -zxvf cmake-2.8.7.tar.gz
# cd cmake-2.8.7
# ./configure --prefix=/usr
# gmake && gmake install
# tar -zxvf bison-2.4.3.tar.gz
# cd bison-2.4.3
# ./configure
# make && make install
# tar -zxvf mysql-5.5.48.tar.gz
# cd mysql-5.5.48
# mkdir /data
# groupadd mysql
# useradd -g mysql mysql
# cmake -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_SSL=yes -DWITH_DEBUG=0
# make && make install
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/data --user=mysql
# cp /usr/local/mysql/support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# chown mysql.mysql /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# groupadd www
# useradd -g www www
# yum -y install net-snmp-devel net-snmp net-snmp-utils
# ln -s /usr/lib64/libldap-2.4.so.2 /usr/lib/libldap-2.4.so.2
# ln -s /usr/lib64/libldap_r.so /usr/lib/libldap_r.so
# ln -s /usr/lib64/libldap_r-2.4.so.2 /usr/lib/libldap_r-2.4.so.2
# ln -s /usr/lib64/libldap.so /usr/lib/libldap.so
# ln -s /usr/local/mysql/lib/libmysqlclient.a /usr/lib/libmysqlclient_r.a
# ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/libmysqlclient_r.so
# ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/libmysqlclient_r.so.18
# ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/libmysqlclient_r.so.18.0.0
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so.18
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so.18.0.0
# ln -s /usr/local/mysql/lib/libmysqlservices.a /usr/lib/libmysqlservices.a
# ln -s /usr/local/mysql/lib/libmysqlclient.a /usr/lib/libmysqlclient.a
# ln -s /usr/lib64/libpng.so /usr/lib/libpng.so
# ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
# ldconfig -v
# tar -zxvf php-5.4.45.tar.gz
# cd php-5.4.45
# ./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 --with-pdo-mysql=/usr/local/mysql --with-iconv-dir=/usr/local --enable-fpm --disable-phar --with-fpm-user=www --with-fpm-group=www --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --with-mhash --enable-mbstring --with-mcrypt --enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets --enable-zip --enable-bcmath --with-snmp --disable-ipv6 --with-ldap --with-xmlrpc --with-gettext
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# cp php.ini-production /usr/local/php/etc/php.ini
# cd /usr/local/php/etc/
# cp php-fpm.conf.default php-fpm.conf
# tar -zxvf pcre-8.12.tar.gz
# cd pcre-8.12
# ./configure --prefix=/usr/local
# make && make install
# tar -zxvf nginx-1.10.2.tar.gz
# cd nginx-1.10.2
# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module --with-file-aio
# make && make install
环境安装完毕
ZABBIX安装及相关配置
1、配置php.ini
# vi /usr/local/php/etc/php.ini
修改如下内容,如果配置参数被注释了,需要取消注释
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 16M ###有时候这里会被设置成32M,但是这里根据后面初始化提示中的信息,被要求设置成16M
max_input_time=300
memory_limit = 128M
2、新建zabbix用户和组
# groupadd zabbix
# useradd -g zabbix zabbix
3、新建zabbix连接数据库用户
# /use/local/mysql/bin/mysql
mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to 'zabbix'@'127.0.0.1' identified by '123456';
4、Zabbix Server安装
# wget http://soft.ileiming.com/zabbix/zabbix-3.2.1.tar.gz
# tar -zxvf zabbix-3.2.1.tar.gz
# cd zabbix-3.2.1
# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --enable-java --with-ldap
# make && make install
检查zabbix是否被添加进入系统服务文件中
# vi /etc/services (查看此文件中是否有这4行内容)
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper
前面已经在mysql里面建立了数据库和用户,现在就需要导入数据库,下面依次导入3个SQL语句
# /usr/local/mysql/bin/mysql zabbix
创建zabbix的的日志文件和连接
# mkdir /var/log/zabbix
# chown zabbix.zabbix /var/log/zabbix
# ln -s /usr/local/zabbix/etc /etc/zabbix
# ln -s /usr/local/zabbix/bin/* /usr/bin/
# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
拷贝启动文件
# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
# chmod 755 /etc/init.d/zabbix_*
# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_server
# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd
配置zabbix_server.conf服务端文件
# vi /etc/zabbix/zabbix_server.conf (修改如下项,如有注释,取消注释)
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=123456
配置zabbix_agentd.conf文件
# vi /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
PidFile=/tmp/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
UnsafeUserParameters=1
Include=/etc/zabbix/zabbix_agentd.conf.d/
拷贝PHP网页文件
# cp -r ./frontends/php/ /data/www/zabbix
启动服务
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2(有可能启动会报错,查libiconv.so.2文件,做个软连接即可)
# /etc/init.d/zabbix_server start
# /etc/init.d/zabbix_agentd start
转载请注明:IT运维空间 » 运维技术 » LNMP环境配置安装ZABBIX 3.2
发表评论