部署Zabbix須要LAMP環境(Linux、Apache、MySQL、PHP),因此首先要安裝Apache(固然,nginx也能夠)、MySQL和PHP。在Ubuntu 16.04下只有php7.0而沒有php5php
#安裝apahce2 sudo apt-get install apache2 #安裝mysql sudo apt-get install mysql-server #安裝php sudo apt-get install php7.0 php7.0-gd libapache2-mod-php7.0 php7.0-mysql php7.0-bcmath php7.0-mbstring php7.0-xml
以上完成了基本環境的安裝,接下來安裝zabbix
html
#獲取3.4zabbix安裝包 wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb
#使用dpkg安裝3.4deb包 dpkg -i zabbix-release_3.4-1+xenial_all.deb #更新apt apt update #安裝zabbix web程序 apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent #拷貝web程序到apache2 sudo cp -r /usr/share/zabbix /var/www/html/zabbix
創建zabbix的庫表,並導入數據mysql
mysql -uroot -p password mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; mysql> quit;
導入表結構和數據,官網的/usr/share/doc/zabbix-server-mysql*/create.sql.gz目錄是錯誤的,並非doc下nginx
zcat /usr/share/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
以後還要修改zabbix_server.conf文件web
sudo nano /etc/zabbix/zabbix_server.conf
配置參考以下,主要是修改密碼sql
DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix12345
完成以上配置後,重啓zabbix-serverapache
sudo /etc/init.d/zabbix-server restart
把zabbix 加入開機啓動ubuntu
systemctl restart zabbix-server zabbix-agent apache2 systemctl enable zabbix-server zabbix-agent apache2