前提條件:
1.完成Linux CentOS 7最小化安裝后基本配置和下載必備插件特幔。
2.關(guān)閉selinux:
編輯/etc/selinux下的config文件
把SELINUX=enforcing修改為SELINUX=disabled
重啟后生效
查看selinux狀態(tài)getenforce
3.關(guān)閉防火墻:
systemctl stop firewalld
開始安裝:
(一)安裝lnmp基本環(huán)境
1.安裝nginx:
1.添加nginx官方源:
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安裝nginx:
yum install -y nginx
3.啟動(dòng)nginx和開機(jī)啟動(dòng)nginx
systemctl start nginx
systemctl enable nginx
在瀏覽輸入IP地址栋豫,看到這個(gè)界面則說明nginx安裝和啟動(dòng)成功酪耕。
20200618171721.png
2.安裝php
1.安裝php以及相關(guān)依賴
yum install -y php php-gd php-mysql php-fpm
2.啟動(dòng)php-fpm和開機(jī)啟動(dòng)php-fpm:
systemctl start php-fpm
systemctl enable php-fpm
3.安裝mysql/mariadb
1.安裝Mysql/mariadb
對(duì)于Zabbix Server和Proxy來說怀大,由于需要將數(shù)據(jù)儲(chǔ)存起來肤粱,所以需要在安裝Zabbix Server和Proxy的服務(wù)器上安裝Mysql數(shù)據(jù)庫捉蚤。
(由于CentOS 7 默認(rèn)使用Mariadb替代Mysql汽纠,所以此處使用Mariadb卫键。同時(shí)為了與Mysql的兼容性,所以使用Mariadb5.5版本)
yum install -y mariadb-server
2.設(shè)置開機(jī)啟動(dòng)并啟動(dòng)mariadb
systemctl enable mariadb
systemctl start mariadb
3.進(jìn)入mariadb進(jìn)行設(shè)置
在命令行輸入以下命令進(jìn)入mariadb
mysql -uroot -p
注:密碼不用輸入直接回車就行
輸入以下命令修改登錄密碼
SET password for 'root'@'localhost'=password('newpassword');
輸入\q退出mysql
4.配置nginx
1.編輯/etc/nginx目錄下nginx.conf文件
去掉gzip on的注釋———開啟nginx gzip壓縮后虱朵,網(wǎng)頁莉炉、css钓账、js等靜態(tài)資源的大小會(huì)大大的減少,從而可以節(jié)約大量的帶寬絮宁,提高傳輸效率梆暮,給用戶快的體驗(yàn)。雖然會(huì)消耗cpu資源绍昂,但是為了給用戶更好的體驗(yàn)是值得的啦粹。
2.編輯/etc/nginx/conf.d目錄下的default.conf文件
修改
location /{
...
...
...
}
模塊中的路徑和首頁末zabbix的路徑為:
root /usr/share/zabbix;
index index.php;
取消
location ~ \.php${
...
...
...
}
模塊的注釋,并且修改
Fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
添加(增大nginx 緩存,否則web頁面會(huì)出錯(cuò))
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;
配置如下圖所示:
20200618175014.png
(二)安裝Zabbix-server
1.安裝Zabbix軟件倉庫
1.添加Zabbix軟件倉庫
安裝軟件倉庫配置包窘游,這個(gè)包包含了 yum(軟件包管理器)的配置文件
rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
2.安裝Zabbix Server
yum install -y zabbix-server-mysql
如果安裝不了唠椭,則vim /etc/yum.repos.d/zabbix.repo編輯zabbix.repo文件,把地址換為阿里云下載地址忍饰。如下圖
微信截圖_20200619160540.png
2.創(chuàng)建數(shù)據(jù)庫
mysql -uroot -p
輸入上面創(chuàng)建mysql的root密碼“newpassword”
create database zabbix character set utf8 collate utf8_bin; #創(chuàng)建數(shù)據(jù)庫實(shí)例
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; #創(chuàng)建并授權(quán)zabbix賬戶并授權(quán)使用zabbix訪問localhost主機(jī)上zabbix數(shù)據(jù)庫下的所有表
\q
3.導(dǎo)入數(shù)據(jù)
使用 MySQL 來導(dǎo)入 Zabbix server 的初始數(shù)據(jù)庫 schema 和數(shù)據(jù)
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
(如果沒有這個(gè)文件夾可以嘗試重復(fù)輸入一遍yum install zabbix-server-mysql)
4.配置Zabbix Server所使用的數(shù)據(jù)庫
vim /etc/zabbix/zabbix_server.conf編輯zabbix_server.conf文件的內(nèi)容
DBHost=localhost 數(shù)據(jù)庫地址
DBName=zabbix 數(shù)據(jù)庫名字
DBUser=zabbix 數(shù)據(jù)庫用戶名
DBPassword=zabbix 數(shù)據(jù)庫用戶密碼
DBPort=3306 數(shù)據(jù)庫端口
5.啟動(dòng)zabbix-server和開機(jī)啟動(dòng)zabbix-server
systemctl start zabbix-server
systemctl enable zabbix-server
(三)安裝zabbix前端
yum install zabbix-web-mysql
vim /etc/httpd/conf.d/zabbix.conf 編輯zabbix.conf文件贪嫂,配置zabbix前端。
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
(四)測試zabbix
訪問nginx配置的虛擬主機(jī)地址艾蓝,若出現(xiàn)以下畫面則zabbix配置成功
微信截圖_20200619154345.png