centos6.6使用yum安裝zabbix3.4
Mysql: mariadb 10.2
Php: 5.6
Httpd: 2.2
System: centos6.6 x86_64
Zabbix: 3.4
yum install –y epel-release
yum groupinstall –y “development tools”
useradd –r –s /sbin/nologin www
安裝mysql
建立一個yum倉庫,內容如下:
cat mariadb10.2.repo
[mariadb10.2]
name=mariadb 10.2
baseurl=http://yum.mariadb.org/10.2/centos6-amd64/
gpgcheck=0
enabled=1
yum install -y MariaDB-server
service mysql start
chkconfig mysql on
mysql_secure_installation #初始化mysql,按照提示完成
登錄mysql
mysql –u root –p
創建zabbix數據庫,後面要用
MariaDB [(none)]> create database zabbix;
grant all privileges on zabbix.* to zabbix@"localhost" identified by "zabbix";
flush privileges;
安裝php
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache \
php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit \
php-pecl-xdebug php-pecl-xhprof php-fpm php-bcmath php-gd php-ldap
yum install *bcmath* --skip-broken
編輯/etc/php.ini 修改如下配置:
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
always_populate_raw_post_data = -1
ldap.max_links = 10
date.timezone Asia/Shanghai
extension=bcmath.so
修改php-fpm的啟動用戶為www
編輯vim /etc/php-fpm.d/www.conf 文件,把user和group從apache改成www
vim /etc/php-fpm.d/www.conf
user = www
group = www
啟動php
service php-fpm restart
chkcnfig php-fpm on
安裝zabbix
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
yum install zabbix-server-mysql
yum install zabbix-proxy-mysql
yum install zabbix-web-mysql
chown -R 755 /etc/zabbix/web/ #修改權限,不然後面會報錯
chown www.www /etc/zabbix/web -R
cp -a /usr/share/zabbix/ /var/www/ #拷貝走zabbix代碼
導入數據庫
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
修改zabbix server配置文件
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=<password>
啟動
service zabbix-server start
chkconfig zabbix-server on
安裝httpd
yum instal –y httpd
修改httpd.conf配置文件
vim /etc/httpd/conf/httpd.conf
ServerName youserver name
找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在後面添加:
AddType application/x-httpd-php .php(使Apcche支持PHP)
AddType application/x-httpd-php-source .php5
找到: DirectoryIndex index.html </IfModule>
添加: DirectoryIndex index.html index.php </IfModule>
找到LoadModule 添加:
LoadModule php5_module modules/libphp5.so
編輯httpd主配置文件,把運行用戶改成www
vim /etc/httpd/conf/httpd.conf
User www
Group ww
編輯zabbix的web配置文件:
cat /etc/httpd/conf.d/zabbix.conf
Alias /zabbix /var/www/zabbix
<Directory “/var/www/zabbix”>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
service httpd restart
chkconfig httpd on
5、使用nginx做zabbix的web服務器
yum install –y nginx
vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name 192.168.10.100;
access_log /var/log/nginx/zabbix_access.log main;
error_log /var/log/nginx/zabbix_error.log;
location /zabbix {
root /var/www;
index index.php index.html index.htm ;
}
location ~ \.php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
fastcgi_index index.php;
include fastcgi_params;
}
}
echo "try_files $uri =404;" >> /etc/nginx/fastcgi_params
chown -R www.www /var/lib/php/
service restart nginx
chkconfig nginx on
5、訪問zabbix
瀏覽器中輸入你的域名/zabbix
192.168.10.100/zabbix
如果能看到頁面說明你成功了一大半了。
如果有紅色的錯誤,是有相關的PHP依賴沒有安裝上,根據提示,使用yum安裝即可。
會讓你選擇自己的設置
數據庫類型為mysql
數據庫地址 localhost
端口號 3306
User zabbix
Pass zabbix
Database zabbix
然後直接下一步。如果有提示說無法創建數據庫配置文件,可以按照他的提示把文件下載下來,放到/etc/zabbix/web下面。要註意文件權限
最後,你可以看到這樣的頁面
默認用戶名為 Admin (首字母大寫)
默認密碼為 zabbix
centos6.6使用yum安裝zabbix3.4