本例环境使用Centos7.3 64位
安装zabbix需要MysqL的支持,下面是快速安装LNMP的方法(使用EZHTTP安装)
安装LNMP
首先创建一个目录存放下载文件:
[root@localhost ~]# mkdir /software [root@localhost software]# cd /software/
安装wget工具:
[root@localhost software]# yum -y install wget
下载EZHTTP安装脚本:
[root@localhost software]# wget --no-check-certificate https://github.com/centos-bz/ezhttp/archive/master.zip?time=$(date +%s) -O ezhttp.zip
启动脚本:
[root@localhost software]# unzip ezhttp.zip [root@localhost software]# cd ezhttp-master [root@localhost ezhttp-master]# chmod +x start.sh [root@localhost ezhttp-master]# ./start.sh
进去选择页面
除了数字选择项需要确认输入,其他的的按回车默认就行:
Nginx 和 apache 都行,个人比较喜欢Nginx
PHP版本5.5-7.1
MysqL版本5.6
[root@localhost ezhttp-master]# ./start.sh ############################################################################# You are welcome to use this script to deploy your linux,hope you like. The script is written by Zhu Maohai. If you have any question. please visit http://www.centos.bz/ezhttp/ and submit your issue.thank you. ############################################################################ 1) LAMP LNMP LANMP Installation. 2) Some Useful Tools. 3) Upgrade Software 4) Exit. please select: 1 you select LAMP LNMP LANMP Installation. 1) LNMP(Nginx MysqL PHP) 2) LAMP(Apache MysqL PHP) 3) LNAMP(Nginx Apache MysqL PHP) 4) back to main menu please input the package you like to install: 1 #################### Nginx setting #################### 1) Nginx-1.8.0 2) tengine-2.1.0 3) openresty-1.9.7.3 4) custom_version 5) do_not_install which Nginx you do select(default do_not_install): 1 your selection: Nginx-1.8.0 Nginx-1.8.0 install location(default:/usr/local/Nginx,leave blank for default): Nginx-1.8.0 install location: /usr/local/Nginx the Nginx-1.8.0 configure parameter is: --prefix=/usr/local/Nginx --with-http_ssl_module --with-openssl=/software/ezhttp-master/soft/openssl-1.0.2h --with-http_sub_module --with-http_stub_status_module --with-pcre --with-pcre=/software/ezhttp-master/soft/pcre-8.33 --with-zlib=/software/ezhttp-master/soft/zlib-1.2.8 --with-http_secure_link_module Would you like to change it?[N/y](default n): you select no,configure parameter will not be changed. Do you need to install Nginx module?[N/y](default n): #################### MysqL setting #################### 1) MysqL-5.1.73 2) MysqL-5.5.54 3) MysqL-5.6.35 4) MysqL-5.7.17 (need about 2GB RAM when building,try MysqL-5.6 if Failed) 5) libMysqLclient18 6) custom_version 7) do_not_install which MysqL you\'d select(default do_not_install): 3 your selection: MysqL-5.6.35 MysqL-5.6.35 install location(default:/usr/local/MysqL,leave blank for default): MysqL-5.6.35 install location: /usr/local/MysqL MysqL data location(default:/usr/local/MysqL/data,leave blank for default): MysqL-5.6.35 data location: /usr/local/MysqL/data MysqL port number(default:3306,leave blank for default): MysqL port number: 3306 MysqL server root password (default:root,leave blank for default): 123456 MysqL-5.6.35 root password: 123456 the MysqL-5.6.35 configure parameter is: -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DSYSCONFDIR=/usr/local/MysqL/etc -DMysqL_UNIX_ADDR=/usr/local/MysqL/data/MysqL.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=complex -DENABLED_LOCAL_INFILE=1 Would you like to change it?[N/y](default n): you select no,configure parameter will not be changed. #################### PHP setting #################### 1) PHP-5.2.17 2) PHP-5.3.29 3) PHP-5.4.43 4) PHP-5.5.27 5) PHP-5.6.15 6) PHP-7.1.0 7) custom_version 8) do_not_install which PHP you\'d select(default do_not_install): 6 your selection: PHP-7.1.0 PHP-7.1.0 install location(default:/usr/local/PHP,leave blank for default): PHP-7.1.0 install location: /usr/local/PHP the PHP-7.1.0 configure parameter is: --prefix=/usr/local/PHP --with-config-file-path=/usr/local/PHP/etc --enable-fpm --enable-bcmath=shared --with-pdo_sqlite --with-gettext=shared --with-iconv --enable-ftp=shared --with-sqlite --with-sqlite3 --enable-mbstring=shared --enable-sockets=shared --enable-zip --enable-soap=shared --with-openssl --with-zlib --with-curl=shared --with-gd=shared --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mcrypt=shared,/opt/ezhttp/libmcrypt-2.5.8 --with-mhash=shared,/opt/ezhttp/mhash-0.9.9.9 --enable-opcache --with-MysqL=MysqLnd --with-MysqLi=shared,MysqLnd --with-pdo-MysqL=shared,MysqLnd --without-pear --with-libdir=lib64 --disable-fileinfo Would you like to change it?[N/y](default n): you select no,configure parameter will not be changed. #################### PHP modules install #################### PHP-7.1.0 version available modules: #################### PHP_modules install #################### 1) fileinfo 2) PHP-gmp 3) PHP-swoole-1.7.20 4) do_not_install please input one or more number between 1 and 4(default do_not_install)(ie.1 2 3): your selection do_not_install #################### other_soft install #################### 1) memcached-1.4.24 2) pure-ftpd-1.0.41 3) PHPMyAdmin-4.4.12-all-languages 4) redis-3.0.3 5) mongodb-linux-x86_64-2.4.9 6) PHPRedisAdmin-1.1.0 7) memadmin-1.0.12 8) rockmongo-1.1.6-fix-auth 9) jdk1.7.0_79 10) jdk1.8.0_66 11) apache-tomcat-7.0.68 12) apache-tomcat-8.0.39 13) do_not_install please input one or more number between 1 and 13(default do_not_install)(ie.1 2 3): 1 2 3 4 6 10 12 your selection memcached-1.4.24 pure-ftpd-1.0.41 PHPMyAdmin-4.4.12-all-languages redis-3.0.3 PHPRedisAdmin-1.1.0 jdk1.8.0_66 apache-tomcat-8.0.39 input memcached-1.4.24 location(default:/usr/local/memcached): memcached location: /usr/local/memcached input pure-ftpd-1.0.41 location(default:/usr/local/pureftpd): pureftpd location: /usr/local/pureftpd Would you like to install web user manager for pureftpd?[N/y](default n): you select not install web manager input PHPMyAdmin-4.4.12-all-languages location(default:/home/wwwroot/PHPmyadmin): PHPmyadmin location: /home/wwwroot/PHPmyadmin input redis-3.0.3 location(default:/usr/local/redis): redis location: /usr/local/redis please input the max memory allowed for redis(ie.128M,512m,2G,4g): 128M 128M input PHPRedisAdmin-1.1.0 location(default:/home/wwwroot/redisadmin): PHPRedisAdmin location: /home/wwwroot/redisadmin input jdk1.8.0_66 location(default:/usr/local/jdk1.8.0_66): jdk8 location: /usr/local/jdk1.8.0_66 input apache-tomcat-8.0.39 location(default:/usr/local/tomcat8): tomcat8 location: /usr/local/tomcat8 #################### your choice overview #################### Package: lnmp *****Nginx Setting***** Nginx: Nginx-1.8.0 Nginx Location: /usr/local/Nginx Nginx Configure Parameter: --prefix=/usr/local/Nginx --with-http_ssl_module --with-openssl=/software/ezhttp-master/soft/openssl-1.0.2h --with-http_sub_module --with-http_stub_status_module --with-pcre --with-pcre=/software/ezhttp-master/soft/pcre-8.33 --with-zlib=/software/ezhttp-master/soft/zlib-1.2.8 --with-http_secure_link_module Nginx Modules: *****MysqL Setting***** MysqL Server: MysqL-5.6.35 MysqL Location: /usr/local/MysqL MysqL Data Location: /usr/local/MysqL/data MysqL Port Number: 3306 MysqL Root Password: 123456 MysqL Configure Parameter: -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DSYSCONFDIR=/usr/local/MysqL/etc -DMysqL_UNIX_ADDR=/usr/local/MysqL/data/MysqL.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=complex -DENABLED_LOCAL_INFILE=1 *****PHP Setting***** PHP: PHP-7.1.0 PHP Location: /usr/local/PHP PHP Configure Parameter: --prefix=/usr/local/PHP --with-config-file-path=/usr/local/PHP/etc --enable-fpm --enable-bcmath=shared --with-pdo_sqlite --with-gettext=shared --with-iconv --enable-ftp=shared --with-sqlite --with-sqlite3 --enable-mbstring=shared --enable-sockets=shared --enable-zip --enable-soap=shared --with-openssl --with-zlib --with-curl=shared --with-gd=shared --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mcrypt=shared,MysqLnd --without-pear --with-libdir=lib64 --disable-fileinfo *****Other Software Setting***** Other Software: memcached-1.4.24 pure-ftpd-1.0.41 PHPMyAdmin-4.4.12-all-languages redis-3.0.3 PHPRedisAdmin-1.1.0 jdk1.8.0_66 apache-tomcat-8.0.39 memcached location: /usr/local/memcached pureftpd location: /usr/local/pureftpd PHPmyadmin_location: /home/wwwroot/PHPmyadmin redis_location: /usr/local/redis PHPRedisAdmin_location: /home/wwwroot/redisadmin jdk8_location: /usr/local/jdk1.8.0_66 tomcat8_location: /usr/local/tomcat8 JAVA_HOME: /usr/local/jdk1.8.0_66 ############################################################## Are you ready to configure your Linux?[Y/n](default y):
安装过程等待即可:
.............................. ..............................
安装成功:
start programs... Starting Nginx daemon: . Starting MysqL.. SUCCESS! Warning: Using a password on the command line interface can be insecure. Starting PHP-fpm done Starting memcached: Start pureftpd.... [OK] Starting Redis server...
使用EZHTTP安装成功后各服务已经打开,输入Linxu 机器IP 访问即可:
恭喜,安装成功了!
开始安装zabbix
配置源
Zabbix在CentOS基本源里不可获得,因此必须配置EPEL 和Zabbix 官方repository,因为需要一款名叫fping的软件(这款软件你下载源码编译安装貌似行不通!),然后其他的yum源将MysqL全部识别为mariadb了,所以想yum安装MysqL,请安装MysqL社区版官方源,或者编译安装,上面的EZHTTP安装脚本就是编译安装
安装EPEL repository
[root@localhost software]# pwd /software [root@localhost software]# yum -y install epel-release
配置ZabbixZone package repository and GPG key
[root@localhost software]# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX [root@localhost software]# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591 [root@localhost software]# yum -y install fping [root@localhost software]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
安装Zabbix server and agent(agent是可选的)
安装Zabbix server and agent:(配置自己监控自己,所以安装了zabbix-agent)
yum -y install zabbix-server-MysqL zabbix-web-MysqL zabbix-agent
可以上zabbix rpm包官网查看或下载相应包
创建MysqL 数据库和用户
[root@localhost software]# MysqL -uroot -p123456
MysqL> create database zabbix character set utf8; MysqL> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix'; MysqL> flush privileges;
数据库导入zabbix template
看yum安装的zabbix-server-MysqL-3.x.x 这个文件的版本是多少就改成多少
[root@localhost software]# zcat /usr/share/doc/zabbix-server-MysqL-3.2.4/create.sql.gz |MysqL -uzabbix -pzabbix -b zabbix
配置Zabbix server
vi /etc/zabbix/zabbix_server.conf
配置下面的几个参数
带#号的就去掉#号,并修改其值
ListenPort=10051 DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/usr/local/MysqL/data/MysqL.sock DBPort=3306
配置zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
配置zabbix server的ip
## Line 95 - Specify Zabbix server ## Server=127.0.0.1 ## Line 136 - Specify Zabbix server ## ServerActive=127.0.0.1 ## Line 147 - Specify Zabbix server Hostname or IP address Hostname=127.0.0.1
修改PHP 设置
修改PHP.ini为zabbix 建议的设置
编辑文件 PHP.ini,
[root@localhost software]# vi /usr/local/PHP/etc/PHP.ini
设置下面的参数:
max_execution_time = 300 max_input_time = 300 memory_limit = 128M post_max_size = 32M upload_max_filesize = 2M date.timezone = Asia/Shanghai
extension=bcmath.so extension=gettext.so extension=sockets.so
安装扩展
[root@localhost ext]# cd /software/ezhttp-master/soft/PHP-7.1.0/ext [root@localhost ext]# pwd /software/ezhttp-master/soft/PHP-7.1.0/ext [root@localhost ext]# cd sockets/ [root@localhost sockets]# /usr/local/PHP/bin/PHPize [root@localhost sockets]# ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config [root@localhost sockets]# cd .. [root@localhost ext]# cd bcmath/ [root@localhost bcmath]# /usr/local/PHP/bin/PHPize [root@localhost bcmath]# ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config [root@localhost bcmath]# cd .. [root@localhost ext]# cd gettext/ [root@localhost gettext]# /usr/local/PHP/bin/PHPize [root@localhost gettext]# ./configure --with-PHP-config=/usr/local/PHP/bin/PHP-config
使用下面命令可以看到有一个扩展存放的目录,我们需要的扩展模块在其中即安装成功
[root@localhost gettext]# make && make install
[root@localhost software]# vi /usr/local/PHP/etc/PHP-fpm.d/www.conf user = www group = www
方法一:使用 apache 服务器
[root@localhost etc]# cd /etc/httpd/
Listen 80 User www Group wwww <IfModule dir_module> DirectoryIndex index.html index.PHP </IfModule>
<IfModule mod_PHP5.c> PHP_value max_execution_time 300 PHP_value memory_limit 128M PHP_value post_max_size 32M PHP_value upload_max_filesize 8M PHP_value max_input_time 300 PHP_value always_populate_raw_post_data -1 PHP_value date.timezone Asia/Shanghai </IfModule>
然后重启apache、MysqL、PHP、zabbix-server
浏览器输入ip/setup.PHP 即可进入zabbix初次web安装界面
方法二:使用 Nginx 服务器
把zabbix程序文件拷贝到我们指定的目录,并修改属主和属组
[root@localhost software]# cp -r /usr/share/zabbix /var/www/ [root@localhost software]# chown -R www:www /var/www/zabbix [root@localhost software]# chown -R www:www /etc/zabbix [root@localhost software]# chown -R www:www /usr/share/zabbix [root@localhost software]# chown -R www:www /usr/lib/zabbix [root@localhost software]# chmod -R 755 /etc/zabbix/web
[root@localhost ~]# cd /usr/local/Nginx/conf/ [root@localhost conf]# mkdir conf.d/
配置Nginx.conf,把新建的目录包含进去
[root@localhost conf]# vi Nginx.conf listen 80 default_server; ===> 改为 listen 90 default_server; root /home/wwwroot/; ===> 改为 # root /home/wwwroot/; include vhost/*.conf; ===> 改为 include /usr/local/Nginx/conf/conf.d/*.conf;
[root@localhost conf]# cd conf.d/ [root@localhost conf.d]# vi zabbix.conf
zabbix.conf 内容如下:
server { listen 80; server_name localhost; root /var/www/zabbix; index index.PHP index.html index.htm; access_log logs/zabbix.access.log; error_log logs/zabbix.error.log; location / { try_files $uri $uri/ /index.PHP?$args; } location ~ .*\.(PHP)?$ { expires -1s; try_files $uri =404; fastcgi_split_path_info ^(.+\.PHP)(/.+)$; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/:/usr/share/zabbix/:/etc/zabbix/web/:/etc/zabbix/; } }
启动zabbix 和 各服务
启动zabbix-server 和zabbix-agent。并设置zabbix-server和zabbix-agent开机自动启动
systemctl start zabbix-server systemctl start zabbix-agent /etc/init.d/Nginx restart chkconfig Nginx on /etc/init.d/MysqLd restart chkconfig MysqLd on /etc/init.d/PHP-fpm restart chkconfig PHP-fpm on systemctl enable zabbix-server systemctl enable zabbix-agent
修改Firewall 和SELinux 设置
开放zabbix端口10050 and 10051
firewall-cmd --permanent --add-port=10050/tcp firewall-cmd --permanent --add-port=10051/tcp
重启firewall
systemctl restart firewalld
如果使用 SELinux,运行以下命令使 Apache 可以和 Zabbix通信
setsebool -P httpd_can_connect_zabbix=1
如果是测试环境可以直接关闭防火墙和selinux
[root@localhost software]# systemctl stop firewalld [root@localhost local]# chkconfig firewalld off
[root@localhost software]# setenforce 0 [root@localhost software]# vi /etc/selinux/config SELINUX=disabled
输入ip/setup.PHP进入zabbix-web界面进行后续安装操作
确认状态都是ok
配置数据库信息(填写上面我们设置的数据库账户和密码:zabbix,zabbix,测试环境可以直接用root)
进入下一步,默认即可
如果出现下面错误
解决方法:
sed -i 's#cgi.fix_pathinfo=0#cgi.fix_pathinfo=1#' /usr/local/PHP/etc/PHP.ini /etc/init.d/PHP-fpm restart
刷新浏览器, 一直下一步
这个是因为PHP 7.1.0类型强化,处理方法也很简单找到Zabbix WEB目录下include/func.inc.PHP文件,执行下面命令,并重启PHP服务:
sed -i '/$last = strtolower(substr($val,-1));/a$val = substr($val,-1);' /var/www/zabbix/include/func.inc.PHP /etc/init.d/PHP-fpm reload
然后刷新页面可以看到已经正常。
ok,初始化完毕。。。
解决图形中文乱码
这个问题是由于zabbix的web端没有中文字库,我们最需要把中文字库加上即可
解决办法如下
1.从windows下控制面板->字体->选择一种中文字库例如“楷体”
2.把它拷贝到zabbix的web端的fonts目录下例如:/var/www/html/zabbix/fonts,确认后缀为ttf
3.修改zabbix的web端/include/defines.inc.PHP
点击(此处)折叠或打开
//define('ZBX_FONT_NAME','graphfont'); define('ZBX_FONT_NAME','simkai'); //define('ZBX_GRAPH_FONT_NAME','graphfont'); // font file name define('ZBX_GRAPH_FONT_NAME','simkai'); // font file name
其中simkai为字库名字,不包含ttf后缀
测试结果:
原文链接:https://www.f2er.com/centos/374425.html