Press "Enter" to skip to content

Zabbix编译安装

一、安装Nginx
1. cd /home/app
2. wget http://nginx.org/download/nginx-1.11.5.tar.gz #下载nginx源码
3. tar zxvf nginx-1.11.5.tar.gz #解压
4. cd nginx-1.11.5
5. yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-dev pcre-devel gcc-c++ #安装依赖
6. ./configure --prefix=/home/app/nginx --with-http_stub_status_module --with-pcre
7. make
8. make install
9. groupadd www-data
10. useradd -r -g www-data -s /bin/false www-data
11. chown -R www-data:www-data /home/app/nginx
12. vim /home/app/nginx/conf/nginx.conf #在开头添加,指定启动进程的用户
user www-data;
13. vim /home/app/nginx/conf/nginx.conf #在http段添加虚拟主机配置
server {
listen 1280;
server_name localhost;

index index.php index.html index.html;
root /home/app/zabbix_web;

location /
{
try_files $uri $uri/ /index.php?$args;
}

location ~^(.+.php)(.*)$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/phpfpm.sock;
}
}

二、安装mysql
1. rpm -qa |grep mysql #查看是否已安装mysql
2. rpm -e mysql-server –nodeps #将上一步显示的mysql相关包卸载
3. groupadd mysql
4. useradd -r -g mysql -s /bin/false mysql
5. vim /etc/passwd #将已存在的mysql用户限制登录
mysql /bin/false
6. cd /home/app
7. wget http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz #下载mysql,已编译
8. tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
9. cd mysql-5.7.16
10. mv mysql-5.7.16 /home/app/mysql
11. chown mysql:mysql /home/app/mysql
12. cd /home/app/mysql
13. mkdir /home/app/mysql/data
14. chown mysql:mysql /home/app/mysql/data
15. ./bin/mysqld --initialize --user=mysql --basedir=/home/app/mysql --datadir=/home/app/mysql/data #初始化mysql,记录临时root密码
16. cp mysql/support-files/my-default.cnf my.cnf
17. ln -s /home/app/mysql/my.cnf /etc/my.cnf
18. vim my.cnf
[mysqld]
basedir = /home/app/mysql
datadir = /home/app/mysql/data
port = 3306
socket = /home/app/mysql/tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /home/app/mysql/tmp/mysql.sock
19. chmod o+r /home/app/mysql
20. chmod o+x /home/app/mysql #避免zabbixserver无法连接mysql
21. cp mysql/support-files/mysql.server /etc/init.d/mysqld #添加到系统服务
22. chmod +x /etc/init.d/mysqld
23. chkconfig --add mysqld
24. chkconfig mysqld on
25. /etc/init.d/mysqld start
26. /home/app/mysql/bin/mysql -uroot -p
alter user 'root'@'localhost' identified by 'xxxxxxx'
27. wget http://repo.mysql.com//mysql57-community-release-el6-9.noarch.rpm
28. rpm -ivh mysql57-community-release-el6-9.noarch.rpm
29. yum install mysql-devel

三、安装php
1. yum -y groupinstall "Development Tools"
2. yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
3. wget http://cl1.php.net/distributions/php-7.0.12.tar.gz
4. tar zxvf php-7.0.12.tar.gz
5. cd php-7.0.12
6. ./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 --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
7. make
8. make test
9. make install
10. cp php.ini-production /usr/local/php/etc/php.ini
11. cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
12. cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
13. vim /usr/local/php/etc/php.ini #修改以下参数
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC
14. vim /usr/local/php/etc/php-fpm.d/www.conf
listen = /var/run/phpfpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
15. /usr/local/php/sbin/php-fpm #启动php-fpm
16. netstat -lnt | grep 9000 #测试php-fpm运行状态

四、zabbix服务端安装配置
1. cd /home/app
2. yum install net-snmp-devel java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
3. wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.11/zabbix-3.2.11.tar.gz
4. tar zxvf zabbix-3.2.11.tar.gz
5. cd zabbix-3.2.11
6. ./configure --prefix=/home/app/zabbix/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
7. make
8. make install
9. groupadd zabbix
10. useradd -g zabbix zabbix
11. chown zabbix:zabbix /home/app/zabbix -R
12. mysql -uroot -p
create database zabbix default charset utf8;
grant all on zabbix.* to zabbix@’%’ identified by ‘zabbix’;
13. mysql -uroot -p zabbix < database/mysql/schema.sql
14. mysql -uroot -p zabbix < database/mysql/images.sql
15. mysql -uroot -p zabbix < database/mysql/data.sql
16. vim /home/app/zabbix/etc/zabbix_server.conf
LogFile=/home/app/zabbix/log/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
DBSocket=/home/app/mysql/tmp/mysql.sock
JavaGateway=127.0.0.1JavaGatewayPort=10052StartJavaPollers=5
17. /home/app/zabbix/sbin/zabbix_server #启动服务端
18. vim /home/app/zabbix/sbin/zabbix_java/settings.sh #配置zabbix_java
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/home/app/zabbix/zabbix_java.pid"
START_POLLERS=5
19. /home/app/zabbix/sbin/zabbix_java/startup.sh #启动zabbix_java

五、zabbix客户端安装配置
1. vim /home/app/zabbix/etc/zabbix_agentd.conf
LogFile=/home/app/zabbix/log/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
ListenPort=10050
Hostname=Zabbix server
2. /home/app/zabbix/sbin/zabbix_agentd #启动客户端

六、zabbix网站配置
1. mkdir /home/app/zabbix_web
2. cp -rp /home/app/zabbix-3.2.11/frontends/php/* /home/app/zabbix_web/
3. chown -R www-data:www-data /home/app/zabbix_web
4. chmod -R 755 /home/app/zabbix_web
5. vim /home/app/zabbix_web/include/defines.inc.php #上传楷体字体到zabbix_web/fonts目录下,修改配置文件以避免乱码
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
/home/app/zabbix_web/fonts下新增simkai.ttf文件

七、确保应用开机自启动
1. chmod +x /etc/rc.d/rc.local
2. vim /etc/rc.d/rc.local
/home/app/nginx/sbin/nginx
/usr/local/php-fpm
/home/app/zabbix/sbin/zabbix_server
/home/app/zabbix/sbin/zabbix_agentd
/home/app/zabbix/sbin/zabbix_java/startup.sh

八、zabbix网站初期配置
1. 浏览器打开http://*.*.*.*
2. 欢迎界面,点击下一步
3. php需求检查,全部为OK方可点击下一步
4. mysql配置,填入mysql服务器信息,点击下一步
5. zabbix服务端详细信息,默认即可,点击下一步
6. zabbix 安装前信息列表,点击下一步
7. 安装完成
8. 登陆zabbix,默认用户名: Admin,密码: zabbix
9. 点击右上角admin,将language一栏改为zh_CN,点击update保存

Be First to Comment

发表评论

电子邮件地址不会被公开。 必填项已用*标注