环境
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 [email protected]"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