1、LAMP 環境搭建 初次安裝可以先關閉selinux 和 firewall 1.1 mariadb資料庫安裝,啟動、加入啟動項 1.2 apache安裝安裝、啟動、加入啟動項 更改mysql root初始密碼: mysql> set password for root@localhost = p ...
1、LAMP 環境搭建
初次安裝可以先關閉selinux 和 firewall
[root@localhost ~]# setenforce 0 [root@localhost ~]# systemctl stop firewalld.service
1.1 mariadb資料庫安裝,啟動、加入啟動項
[root@localhost ~]# yum install mariadb-*
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled;
vendor preset: disabled)
Active: active (running) since 日 2019-02-24 11:10:49 CST; 16s
ago
[root@localhost ~]# systemctl enable mariadb.service
更改mysql root初始密碼:
mysql> set password for root@localhost = password('123');
mysql> flush privileges; #立即生效
1.2 apache安裝安裝、啟動、加入啟動項
[root@localhost ~]# yum install httpd.x86_64 root@localhost ~]# systemctl start httpd.service [root@localhost ~]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since 日 2019-02-24 11:19:16 CST; 5s ago [root@localhost ~]# systemctl enable httpd.service
1.3 php 安裝
[root@localhost ~]# yum install php.x86_64
2、zabbix程式包安裝部署
2.1 下載並安裝zabbix rpm包倉庫
[root@localhost ~]# wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm [root@localhost ~]# rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm
2.2 安裝zabbix 相關程式包
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent #如果zabbix源慢,可以改變阿裡源
2.4 安裝初始化資料庫
創建zabbix資料庫,並對zabbix授予許可權
MariaDB [(none)]> create database zabbix character set utf8; #這裡資料庫一定要指定字元集,要不在前端歷史操作是亂碼,因為歷史操作是保存在資料庫里的。 MariaDB [(none)]> flush privileges;
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by '111';
導入資料庫
create.sql /usr/share/doc/zabbix-server-mysql-4.0.0
# mysql -u zabbix -p zabbix < create.sql #導入create.sql
啟動Zabbix Server進程
2.5 在zabbix_server.conf中編輯資料庫配置
# vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix
2.6 啟動Zabbix Server進程,並加入啟動項
# systemctl start zabbix-server# systemctl start zabbix-server.service# systemctl status zabbix-server.service
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: active (running) since 日 2019-02-24 15:59:37 CST; 6s ago# systemctl enable zabbix-server.service
2.7 編輯Zabbix前端的PHP配置
Zabbix前端的Apache配置文件位於 /etc/httpd/conf.d/zabbix.conf 。一些PHP設置已經完成了配置。
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 #需要重啟Apache Web伺服器
# systemctl restart httpd.service
Zabbix前端可以在瀏覽器中通過 http://localhost/zabbix 訪問
zabbix登錄預設用戶:名 密碼: admin zabbix
zabbix安裝完生成/etc/zabbix/web/zabbix.conf.php,可做資料庫拆分配置用
2.8 abbix_agentd.conf 配置
Server=127.0.0.1 #允許接受某主機發來的數據
ServerActive=127.0.0.1
啟動zabbix_agentd
2.8 註意
每次改動配置文件都要重啟一遍避免出現 類似 “zabbix server is running no”頁面報錯