基於LNMP的Zabbix4.0.1部署


 
一 安裝源和Zabbix的依賴包:
1 添加源
wget -q -O - http://www.atomicorp.com/installers/atomic | sh
2 安裝LAMP環境
yum -y install nginx php php-mysql mysql mysql-server vim nmap php-fpm
3 安裝拓展包
yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-gd php-xmlwriter libevent-devel libevent pcre*
 
二 添加用戶:
 
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
 
三 創建數據庫並添加授權賬號:
 
#啟動mysql數據庫
/etc/init.d/mysqld start
#解決中文亂碼問題
mysql -e "create database zabbix character set utf8;"
#對用戶進行授權
mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'admin@123';"
 
四 下載zabbix
zabbix下載地址:
 
1 下載源碼
wget "https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz/download" -O zabbix-4.0.1.tar.gz
 
2 編譯安裝
tar -zxvf zabbix-4.0.1.tar.gz
cd zabbix-4.0.1
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
make -j 4 && make install
 
4 #導入數據庫
cd /tmp/zabbix-4.0.1
mysql -uzabbix -p'admin@123' -hlocalhost zabbix < database/mysql/schema.sql
mysql -uzabbix -p'admin@123' -hlocalhost zabbix < database/mysql/images.sql
mysql -uzabbix -p'admin@123' -hlocalhost zabbix < database/mysql/data.sql
 
5 #修改配置在zabbix包路徑下
sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf
sed -i 's/^.*DBPassword=.*$/DBPassword=admin@123/g' /usr/local/zabbix/etc/zabbix_server.conf
sed -i 's/^DBSocket=.*$/DBSocket=\/var\/lib\/mysql\/mysql.sock /usr/local/zabbix/etc/zabbix_server.conf
cp -r frontends/php /var/www/html/zabbix
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
 
6 #添加服務端口
cat >>/etc/services <<EOF
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF
 
7 #修改php.ini
sed -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /etc/php.ini
sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /etc/php.ini
sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /etc/php.ini
sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /etc/php.ini
sed -i 's/^\(.*\)always_populate_raw_post_data =.*$/always_populate_raw_post_data = .*/g' /etc/php.ini
 
8#配置nginx
vim /etc/nginx/conf.d/default.conf
 
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 10.0.5.150;
location / {
root /var/www/html/zabbix;
index index.php index.html;
}
location ~ \.php$ {
root /var/www/html/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_scrip
t_name;
include fastcgi_params;
}
 
9#修改權限
chown -R root:root /var/lib/php/
chmod 777 /var/lib/php/session/
 
10 #啟動服務
/etc/init.d/nginx start
/etc/init.d/php-fpm start
/etc/init.d/mysqld start
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on
echo "/etc/init.d/zabbix_server start" >> /etc/rc.local
echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.local
 
五 WEB頁面配置:
訪問http://10.0.5.150/setup.php
1、確認每個Required都是ok的才會顯示Next按鈕,如果有Fail的需要完善系統要求
2、這里主要下,出現Fail的原因是zabbix的配置文件沒有,需要點擊“Download configuration file”將zabbix.conf.php下載到本地在上傳到服務器的zabbix/conf/目錄下即可
 
 
到此web頁面配置完畢,直接訪問IP就可以登錄,zabbix的默認登陸賬號是admin,密碼是zabbix
 
3、更換中文字體,登陸后在頁面的右上邊點擊“Prefile”
 
4、在Language選項中選擇“Chinese(zh_CN)”,然后Save


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM