-
安装依赖
yum install pcre* #为了支持rewrite功能 yum install openssl openssl-devel yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y #编译需要的依赖包
-
安装nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz tar xvf nginx-1.12.2.tar.gz cd nginx-1.12.2 执行./configure --prefix=/usr/local/nginx-1.12.2 --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre ####--with-http_spdy_module 1.9之后没有了,--with-http_v2_module取而代之 make && make install
-
查看防火墙是否关闭(如果虚拟机可以访问nginx,物理机不能访问nginx)
sudo systemctl status firewalld 查看防火墙状态 sudo systemctl stop firewalld停止防火墙 systemctl disable firewalld.service 禁止开机启用防火墙 vim /etc/selinux/config 进入配置文件 设置:SELINUX=disabled(重启才生效) #或者防火墙开放80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent
-
安装mysql 5.7
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm yum localinstall mysql57-community-release-el7-7.noarch.rpm yum repolist enabled | grep "mysql.*-community.*" yum install mysql-community-server service mysqld start grep 'temporary password' /var/log/mysqld.log #记录随机密码 oHr6jwY>Jeay mysql_secure_installation #初始化 mysql -u root -p
-
新建以及初始化数据库zabbix
create database zabbix; use zabbix; source /root/zabbix-3.4.3/database/mysql/schema.sql; source /root/zabbix-3.4.3/database/mysql/data.sql; source /root/zabbix-3.4.3/database/mysql/images.sql;
-
安装php 5.6 稳定版本
yum -y groupinstall "Development Tools" yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y 编译需要的依赖包 wget http://php.net/get/php-5.6.28.tar.gz/from/this/mirror -O php-5.6.28.tar.gz cd php-5.6.28.tar.gz 安装ldap,如果报错无法解决去掉-with-ldap编译 yum -y install openldap openldap-devel cp -frp /usr/lib64/libldap* /usr/lib/ ./configure -prefix=/usr/local/php -with-config-file-path=/usr/local/php/etc -with-bz2 -with-curl -enable-ftp -enable-sockets -disable-ipv6 -with-gd -with-jpeg-dir=/usr/local -with-png-dir=/usr/local -with-freetype-dir=/usr/local -enable-gd-native-ttf -with-iconv-dir=/usr/local -enable-mbstring -enable-calendar -with-gettext -with-libxml-dir=/usr/local -with-zlib -with-pdo-mysql=mysqlnd -with-mysqli=mysqlnd -with-mysql=mysqlnd -with-ldap -enable-dom -enable-xml -enable-fpm -with-libdir=lib64 -enable-bcmath make make install #配置php #编辑php.ini-production #修改如下参数 max_execution_time = 300 memory_limit = 128M post_max_size = 16M upload_max_filesize = 2M max_input_time = 300 date.timezone = PRC cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #启动php-fpm,占用端口9000 /usr/local/php/sbin/php-fpm
-
安装zabbix
#下载zabbix wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.3/zabbix-3.4.3.tar.gz #解压 tar xvf zabbix-3.4.3 cd zabbix-3.4.3 #创建zabbix用户(使用root启动时,会自动找zabbix启动) centos: groupadd --system zabbix useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix ubuntu: addgroup --system --quiet zabbix adduser --quiet --system --disabled-login --ingroup zabbix --home /var/lib/zabbix --no-create-home zabbix #编译 #找到mysql_config_editor的位置 find / -name "mysql_config*" #安装 yum install mysql-devel -y #如果编译遇到mysql文件冲突,则可能是版本冲突,使用rpm下载 wget ftp://ftp.pbone.net/mirror/dev.mysql.com/pub/Downloads/MySQL-5.7/mysql-community-devel-5.7.25-1.el7.x86_64.rpm
yum localinstall mysql-community-devel-5.7.25-1.el7.x86_64.rpm
yum install net-snmp-devel -y yum install libevent-devel -y #配置zabbix server和agent ./configure --enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 make make install
-
配置server和agentd
#启动脚本在 /usr/local/sbin #配置文件在 /usr/local/etc vim /usr/local/etc/zabbix_server.conf DBName=zabbix DBUser=root DBPassword=123456 DBPort=3306 vim /usr/local/etc/zabbix_agentd.conf Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server
-
配置nginx zabbix
要保证前端文件非root用户有权限
cp -r /root/zabbix-3.4.3/frontends/php/* /data/zabbix-frontend sudo chmod -R 777 /data/zabbix-frontend # vim /usr/local/nginx-1.12.2/conf/nginx.conf server { listen 80; server_name localhost; #charset koi8-r; access_log /root/logs/zabbix.access.log main; #最上面的log_format注释要取消 index index.html index.php index.html; root /data/zabbix-frontend; location / { try_files $uri $uri/ /index.php?$args; } location ~ ^(.+.php)(.*)$ { #root /data/zabbix-frontend; fastcgi_split_path_info ^(.+.php)(.*)$; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param PATH_INFO $fastcgi_path_info; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #include fastcgi_params; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
- 如果安装之后,zabbix页面报错zabbix server is not running。需要查看/tmp/zabbix_server.log日志,然后再启动/usr/local/sbin/zabbix_server
官方安装:https://www.zabbix.com/download?zabbix=3.0&os_distribution=centos&os_version=7&db=mysql