centos编译安装zabbix-4.2.4基于LNMP架构(超

2019-07-25  本文已影响0人  hsyman
环境说明:centos6.8
selinux 关闭 iptables 关闭

准备安装源码包:
openssl-1.0.2l.tar.gz 下载点我
nginx-1.12.2.tar.gz 下载点我
pcre-8.39.tar.gz 下载点我
zlib-1.2.8.tar.gz 下载点我
libmcrypt-2.5.8.tar.gz 下载点我
php-5.6.31.tar.gz 下载点我(国内下载地址)国外下载地址
fping-3.12.tar.gz 下载点我
zabbix-4.2.4.tar.gz 下载点我
mysql-5.6.24

安装工具包

yum -y groupinstall "Development Tools"
yum -y install cmake

部署MySQL

tar -xf mysql-5.6.24.tar.gz
cd mysql-5.6.24
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql/ -DMYSQL_DATADIR=/opt/mysql/data/ -DSYSCONFDIR=/opt/mysql/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/opt/mysql/etc/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
PATH=$PATH:/opt/mysql/bin/:/opt/mysql/bin/
export PATH

mysql 首次进入不需要密码
> set password=password('设置的密码');
> create database zabbix;
> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '密码2';
> flush privileges;

安装zlib

tar -xf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure --shared
make && make install

安装openssl

tar -xf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l/
./config shared zlib
make && make install
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/ssl/lib/libssl.so.1.0.0 /usr/local/lib64/libssl.so
echo "/usr/local/ssl/lib/" >> /etc/ld.so.conf
ldconfig -v

安装nginx

tar -xf pcre-8.39.tar.gz
tar -xf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure \
--prefix=/opt/nginx \
--with-http_dav_module \
--with-http_stub_status_module \
--with-http_addition_module \
--with-http_sub_module  \
--with-http_flv_module \
--with-http_mp4_module \
--with-pcre=/root/pcre-8.39 \
--with-zlib=/root/zlib-1.2.8 \
--with-openssl=/root/openssl-1.0.2l \
--with-http_ssl_module \
--with-http_gzip_static_module \
--user=www --group=www
make && make install
groupadd www
useradd -s /sbin/nologin -g www www

部署PHP

tar -xf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
tar -xf php-5.6.31.tar.gz
cd php-5.6.31
./configure --prefix=/opt/php56 --with-config-file-path=/etc  --with-mysql --with-mysqli --with-mysql-sock --with-gd --with-iconv --with-libxml-dir=/usr --with-mhash --with-mcrypt --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-ldap
make && make install
;date.timezone =  改为 date.timezone = Asia/Shanghai
short_open_tag = Off 改为 short_open_tag = On
post_max_size = 8M 改为 post_max_size = 16M
max_execution_time = 30 改为 max_execution_time = 300
max_input_time = 60 改为 max_input_time = 300
always_populate_raw_post_data = -1 去掉注释
mbstring.func_overload = 0 去掉注释
pid = run/php-fpm.pid
user = www
group = www
listen = 127.0.0.1:9000

部署zabbix

grouapdd zabbix
useradd -s /sbin/nologin -g zabbix zabbix
tar -xf fping-3.12.tar.gz
cd fping-3.12
./configure
make && make install
chown root:zabbix /usr/local/sbin/fping
chmod 4710 /usr/local/sbin/fping
tar -xf zabbix-4.2.4.tar.gz
cd zabbix-4.2.4
./configure \
--prefix=/opt/zabbix \
--enable-server \
--enable-agent \
--with-mysql \
--with-net-snmp \
--with-libcurl \
--with-openipmi \
--enable-java
如本机已安装MySQL,可以指定mysql_config文件位置  --mysql=/.../mysql_config
如需监控tomcat 需加上--enable-java 编译参数
make && make install
LogFile=/opt/zabbix/logs/zabbix_server.log
PidFile=/opt/zabbix/logs/zabbix_server.pid
SocketDir=/opt/zabbix/logs/
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=密码2
DBPort=3306
FpingLocation=/usr/sbin/fping

mkdir /opt/zabbix/logs
chown -R zabbix:zabbix /opt/zabbix/

Starting zabbix_server: /etc/init.d/functions: line 722: /usr/local/sbin/zabbix_server: No such file or directory
[FAILED]
vim /etc/init.d/zabbix-server

BASEDIR=/opt/zabbix
按照实际情况修改BASEDIR
以下为修改内容部分,并非全部配置文件内容,仅供参考
user www www;
...
        location / {
            root   html;
            index  index.php;
        }
...
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
...

浏览器访问

http://localhostIP/zabbix

如何配置zabbix,且待更新

上一篇下一篇

猜你喜欢

热点阅读