ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# zabbix的安装 > * Zabbix监控架构至少需要server,agent,web模块。mysql、web部分和server安装在同一台机器上。 > * Zabbix安装前服务器要做时间同步(ntp) 1.创建用户和用户组(Zabbix默认使用Zabbix用户) ~~~ sudo groupadd zabbix sudo adduser zabbix sudo usermod -g zabbix zabbix ~~~ * * * * * ### 1. 安装依赖 * 在安装过程中可能会缺少依赖,慢慢安装吧!有点keng。 ~~~ sudo apt-get -y install libxml2-devlibxml2 make zlib1g.dev zlib1g libcurl4-openssl-devlibjpeg-dev libpng-dev libfreetype6-dev ~~~ > * 发生这个错误,缺少BZip2 ![](https://box.kancloud.cn/305c26dbe3147a3a37f6573d3a289182_607x53.png) > 解决办法:下载 bzip2-1.0.6.tar.gz > sudo make && sudo make install * * * * * ### 2. 安装PHP ~~~ #安装编译套件 sudo apt-get -y install build-essential #安装php前端需要的包 sudo apt-get install -y libmysqlclient15-dev php5-gd php5-mysql #安装zabbix需要的包,snmp\curl\ssl\fping sudo apt-get -y install snmp libsnmp-dev snmpd libcurl4-openssl-dev fping sudo apt-get -y install php5-fpm ~~~ >* 下载PHP `wget http://cn2.php.net/get/php-5.5.35.tar.gz/from/this/mirror` >* 安装编译 `mv mirror php-5.5.35.tar.gz && tar xvf php-5.5.35.tar.gz && cd php-5.5.35` ~~~ ./configure --prefix=/usr/local/product/php-5.5.35 --with-config-file-path=/usr/local/product/php-5.5.35/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 --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath ~~~ ~~~ sudo make sudo make install sudo ln -s /usr/local/product/php-5.5.35 /usr/local/php sudo cp php.ini-production /usr/local/php/etc/php.ini cd /usr/local/php/etc/ sudo cp php-fpm.conf.default php-fpm.conf ~~~ > * 修改PHP参数 ~~~ sudo vim /etc/php5/fpm/php.ini ~~~ > * 做以下修改 ~~~ post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = "Asia/Shanghai" ~~~ * 重启php ~~~ sudo service php5-fpm restart ~~~ * * * * * ### 3.MySQL部分 ~~~ mysql> use mysql; mysql>create database zabbix character set utf8; mysql>grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix'; mysql>flush privileges; ~~~ ### 4. 安装zabbix #### 4.1 安装server ~~~ wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+trusty_all.deb sudo dpkg -i zabbix-release_3.0-1+trusty_all.deb sudo apt-get update zabbix-frontend-php #web部分 sudo apt-get install zabbix-server-mysql zabbix-frontend-php ~~~ * 如果没有mysql,上一步中会自动安装mysql。有就不安装。 > * 修改配置server文件 ~~~ vim /etc/zabbix/zabbix_server.conf ~~~ > * 做以下修改 ~~~ LogFile=/tmp/zabbix_server.log PidFile=/tmp/zabbix_server.pid DBHost=192.168.2.21 #如果远程连接MySQL,一定要改,疼啊 DBName=zabbix DBUser=zabbix DBPassword=zabbix DBPort=3306 ~~~ #### 4.2 初始化数据库(安装zabbix后执行) ~~~ cd /usr/share/doc/zabbix-server-mysql ls sudo gunzip create.sql.gz mysql -uzabbix -pzabbix zabbix <create.sql ~~~ * 安装agent(不用重复做) ~~~ wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+trusty_all.deb sudo dpkg -i zabbix-release_3.0-1+trusty_all.deb sudo apt-get update sudo apt-get install zabbix-agent ~~~ `sudo vim /etc/zabbix/zabbix_agentd.conf` * 做以下修改 ~~~ Server=192.168.0.157 ServerActive=192.168.0.157 Hostname=bigdata2 ~~~ * 因为安装agent时会启动agent进程,在修改配置文件后要重启agent服务。 `sudo service zabbix-agent restart` ### 5.nginx(web配置) [Zabbix安装](Zabbix安装.md) > * 修改nginx配置文件 `sudo vim /etc/nginx/nginx.conf` ~~~ user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server { listen 8088; server_name localhost; # access_log /var/log/nginx/zabbix.log main; root /usr/share/zabbix/; index index.php; location /{ try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } } } ~~~ * 登录配置就行了端口:8088,账号:Admin,密码:zabbix