zabbix-3.0.4
mysql-5.7.17
libiconv-1.14.tar.gz
php-5.6.30
yum安装 nginx mysql php
yum源
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
[webtatic]
name=Webtatic Repository EL6 - $basearch
#baseurl=http://repo.webtatic.com/yum/el6/$basearch/
mirrorlist=http://mirror.webtatic.com/yum/el6/$basearch/mirrorlist
failovermethod=priority
enabled=0
gpgcheck=0
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://mirrors.aliyun.com/epel/6/$basearch
http://mirrors.aliyuncs.com/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
[remi]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
enabled=1
gpgcheck=0
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.0/rhel/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/6/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
/etc/nginx/conf.d/default.conf nginx配置文件目录
/usr/share/nginx/html/ nginx root目录
/etc/httpd/conf.d/php.conf /etc/php.ini php配置
/etc/zabbix/web/zabbix.conf.php
/etc/httpd/conf.d/php.conf
which nginx #查看nginx是否存在
which php #查看php是否存在
which mysql #查看mysql是否存在
yum install pcre* gcc gcc-c++ autoconf automake zlib libxml libjpeg freetype libpng gd curl zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl openssl-devel bzip2-devel crypto libscrypt glibc net-snmp-devel -y
yum install cmake gcc* ncurses-devel -y
yum install mysql-devel nginx php php-fpm php-mysql -y
如果缺少bcmath 。。。。 则yum install php-bcmath 。。。。。。。。。。。。。
nginx部分:
修改nginx配置文件让PHP的请求转发到php-fpm所绑定的ip和端口上:
vi /etc/nginx/conf.d/default.conf #行[37-43]
去掉#号:
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
验证是否处理请求PHP文件:
vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
检查是否可以通过php操作mysql数据库:
vi /usr/share/nginx/html/db.php
<?php
@mysqli_connect("localhost","root","","mysql") or die("connect mysql failed\n");
echo "connect ok\n";
---------------------------------------------------------
php /usr/share/nginx/html/db.php #用命令行执行php
http://182.92.73.109/db.php #在浏览器执行
修改php.ini vi /etc/php.ini
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
post_max_size = 32M
memory_limit = 128M
mbstring.func_overload = 2
yum安装zabbix
https://www.zabbix.com/documentation/3.4/zh/manual/installation/install_from_packages 官方文档,注意版本问题。
#rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
#yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
然后导入初始架构(Schema)和数据。
# cd /usr/share/doc/zabbix-server-mysql-3.1.14 # zcat create.sql.gz | mysql -uroot -p zabbix
在zabbix_server.conf中编辑数据库配置
# vi /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix
启动 zabbix-server:
#service zabbix-server start
编辑Zabbix前端的PHP配置
#vi /etc/httpd/conf.d/php.conf
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数据库
mysql -u root -p #输入密码,进入MySQL控制台
create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8
grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘;
#新建账户zabbix,密码zabbix
flush privileges; #再次刷新系统授权表
grant all on zabbix.* to ‘zabbix‘@‘localhost‘ identified by ‘zabbix‘ with grant option; #允许账户zabbix能从本机连接到数据库zabbix
flush privileges; #再次刷新系统授权表
use zabbix #进入数据库,并刷新数据库,一定要按照sql文件顺序
source /home/soft/zabbix-3.0.0alpha2/database/mysql/schema.sql #导入脚本文件到zabbix数据库
source /home/soft/zabbix-3.0.0alpha2/database/mysql/images.sql #导入脚本文件到zabbix数据库
source /home/soft/zabbix-3.0.0alpha2/database/mysql/data.sql #导入脚本文件到zabbix数据库
cd /usr/share/doc/zabbix-server-mysql-3.0.14
mysql -uzabbix -p zabbix < create.sql
mysql注意事项:
编辑zabbix_server.conf文件
vi /etc/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
zabbix界面汉化
vi /usr/share/zabbix/include/locales.inc.php
找到zh_CN 将,flase改为true
web设置:administration-->users-->admin-->language