zabbix3.4安装(centos7)
2018-10-09 本文已影响0人
ming416
zabbix3.4 centos7 安装
1:选取平台方式LNMP
linux 7.5.1804 + nginx 1.41.0 + mysql 5.7.23 +php 7.2.10
2: 开始安装
2.1 安装nginx
我自己重新编译的nginx,直接放入放到服务器的/opt/ming下
ashs.png
2.2 安装mysql
直接官网的repo rpm包
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
修改下repo把5.7放开
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-
community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
安装
yum install -y mysql mysql-server
[root@localhost ming]# mysql -V
mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using EditLine wrapper
2.3 安装php
安装php依赖包
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel libmcrypt libmcrypt-devel gcc
下载php
wget http://cn2.php.net/distributions/php-7.2.10.tar.gz
编译
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=ming --with-fpm-group=ming --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache
make && make install
编辑配置文件
cp ./php.ini-production /etc/php.ini #从php源代码中拷贝php.ini-production 到并命名为 /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
启动
php-fpm /etc/init.d/php-fpm start
3:配置
3.1 nginx 配置
server{
listen 80;
server_name 127.0.0.1;
root /data/www; # 该项要修改为你准备存放相关网页的路径
location / {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
rewrite ^/(.*)$ /index.php/$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
#rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
}
}
#proxy the php scripts to php-fpm
location ~ \.php {
include fastcgi_params;
##pathinfo支持start
#定义变量 $path_info ,用于存放pathinfo信息
set $path_info "";
#定义变量 $real_script_name,用于存放真实地址
set $real_script_name $fastcgi_script_name;
#如果地址与引号内的正则表达式匹配
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
#将文件地址赋值给变量 $real_script_name
set $real_script_name $1;
#将文件地址后的参数赋值给变量 $path_info
set $path_info $2;
}
#配置fastcgi的一些参数
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
###pathinfo支持end
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}
location ^~ /data/runtime {
return 404;
}
location ^~ /application {
return 404;
}
location ^~ /simplewind {
return 404;
}
}
3.2 zabbix-server配置
主要是DB相关配置
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpass
3.3 php 配置
3.3.1 修改/etc/php.ini
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
date.timezone = Asia/Shanghai
3.3.2修改php用户跟组
vi /usr/local/php/etc/php-fpm.d/www.conf
user = ming
group = ming
3.3.3修改zabbix-server php DB源
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbixpass';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
4:启动
启动zabbix
systemctl enable zabbix-agent &&systemctl start zabbix-agent
启动nginx
./ming
大功告成!!!
image.png
注意事项
1:修改db源时,如果不用elasticearch 一定要注释掉,要不然页面会报错
2:修改nginx中的zabbix目录权限,要跟php配置的用户组一样。