环境:
CentOS:6.9 IP:192.168.1.92 JDK:1.7.0.45 ngingx:1.13.6 MysqL:5.7.21-linux-glibc2.5-x86_64 PHP:5.6.31 zabbix:3.4.2 源码包存放路径:/data/tools/ 安装路径:/usr/local/
1.关闭防火墙和selinux
1.1. 关闭iptables
]#serviceiptablesstop iptables:SettingchainstopolicyACCEPT:filter[OK] iptables:Flushingfirewallrules:[OK] iptables:Unloadingmodules:[OK] ]#chkconfig--level35iptablesoff
1.2. 关闭selinux
]#sed-i's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config ]#setenforce0 ]#getenforce#查看selinux的模式 Disabled
开启模式显示结果:Enforcing 关闭模式显示结果:Disabled
2.二进制安装JDK(1.7.0.45):用于java-geteway
2.1. 上传JDK1.7到/data/tools/目录下,解压:
]#tarxfjdk-7u45-linux-x64.tar.gz-C/opt/
2.2. 添加环境变量,添加Java进程;
]#vim/etc/profile #java exportJAVA_HOME=/opt/jdk1.7.0_45 exportPATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH exportCLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib ]#source/etc/profile #使配置文件立即生效; ]#echo$PATH ]#java-version#验证 javaversion"1.7.0_45" Java(TM)SERuntimeEnvironment(build1.7.0_45-b18) JavaHotSpot(TM)64-BitServerVM(build24.45-b08,mixedmode)
3.安装编译工具
]#yuminstallgccgcc-c++makeautomakeautoconf 包gcc-4.4.7-18.el6.x86_64已安装并且是最新版本 包gcc-c++-4.4.7-18.el6.x86_64已安装并且是最新版本 包1:make-3.81-23.el6.x86_64已安装并且是最新版本 包automake-1.11.1-4.el6.noarch已安装并且是最新版本 包autoconf-2.63-5.1.el6.noarch已安装并且是最新版本 无须任何处理
4.源码安装ngingx(1.13.6)
4.1 下载解压编译
]#yuminstallpcre-developenssl-devel 软件包架构版本仓库 ========================================================= 正在安装: openssl-develx86_641.0.1e-57.el6base pcre-develx86_647.8-7.el6base 为依赖而安装: keyutils-libs-develx86_641.4-5.el6base krb5-develx86_641.10.3-65.el6base libcom_err-develx86_641.41.12-23.el6base libkadm5x86_641.10.3-65.el6base libselinux-develx86_642.0.94-7.el6base libsepol-develx86_642.0.41-4.el6base zlib-develx86_641.2.3-29.el6base 为依赖而更新: e2fsprogsx86_641.41.12-23.el6base e2fsprogs-libsx86_641.41.12-23.el6base krb5-libsx86_641.10.3-65.el6base libcom_errx86_641.41.12-23.el6base libssx86_641.41.12-23.el6base opensslx86_641.0.1e-57.el6base ============================================================ ]#useradd-u888-M-s/sbin/nologinwww ]#mkdir-pv/data/tools/ ]#cd/data/tools/ ]#wgethttp://Nginx.org/download/Nginx-1.13.6.tar.gz ]#tarxfNginx-1.13.6.tar.gz ]#cdNginx-1.13.6 ]#./configure--prefix=/usr/local/Nginx-1.13.6--user=www--group=www--with-http_ssl_module--with-http_stub_status_module ]#echo$? 0 ]#make&&makeinstall ]#ln-s/usr/local/Nginx-1.13.6/usr/local/Nginx
4.2 配置
]#cat/usr/local/Nginx/conf/Nginx.conf#全部替换 worker_processes1; events{ worker_connections1024; } http{ includemime.types; default_typeapplication/octet-stream; log_formatmain'$remote_addr-$remote_user[$time_local]"$request"' '$status$body_bytes_sent"$http_referer"' '"$http_user_agent""$http_x_forwarded_for"'; sendfileon; keepalive_timeout65; server{ listen80; server_namelocalhost; access_loglogs/host.access.logmain; roothtml; indexindex.PHPindex.htmlindex.htm; error_page500502503504/50x.html; location=/50x.html{ roothtml; } location~.*\.(PHP|PHP5)?${ fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.PHP; includefastcgi.conf; } } }
4.3 启动Nginx
]#cd/usr/local/Nginx/sbin ]#./Nginx ]#ss-tnl|grep80
5.二进制安装MysqL(5.7.15)
5.1. 安装MysqL数据库
参考:http://blog.51cto.com/moerjinrong/2092614
5.2. 增加zabbix用户及授权
]#MysqL-uroot-p ]#MysqL>createdatabasezabbixcharactersetutf8collateutf8_bin; ]#MysqL>grantallprivilegesonzabbix.*to"zabbix"@"%"identifiedby'<password>'; ]#MysqL>quit;
6.源码安装PHP(5.6.31)
6.1 安装依赖包
]#wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo ]#yuminstallcurlcurl-develfreetypefreetype-develgdgd-devellibjpeglibjpeg-devellibjpeg-turbo-devel 软件包架构版本仓库 ================================================================ 正在安装: freetype-develx86_642.3.11-17.el6base gdx86_642.0.35-11.el6base gd-develx86_642.0.35-11.el6base libcurl-develx86_647.19.7-53.el6_9updates libjpeg-turbo-develx86_641.2.1-3.el6_5base 正在升级: curlx86_647.19.7-53.el6_9updates 为依赖而安装: fontconfig-develx86_642.8.0-5.el6base libX11-develx86_641.6.4-3.el6base libXau-develx86_641.0.6-4.el6base libXpmx86_643.5.10-2.el6base libXpm-develx86_643.5.10-2.el6base libidn-develx86_641.18-2.el6base libpng-develx86_642:1.2.49-2.el6_7base libxcb-develx86_641.12-4.el6base xorg-x11-proto-develnoarch7.7-14.el6base 为依赖而更新: libX11x86_641.6.4-3.el6base libX11-commonnoarch1.6.4-3.el6base libcurlx86_647.19.7-53.el6_9updates libxcbx86_641.12-4.el6base ================================================================= 包curl-7.19.7-53.el6_9.x86_64已安装并且是最新版本 包libcurl-devel-7.19.7-53.el6_9.x86_64已安装并且是最新版本 包freetype-2.3.11-17.el6.x86_64已安装并且是最新版本 包freetype-devel-2.3.11-17.el6.x86_64已安装并且是最新版本 包gd-2.0.35-11.el6.x86_64已安装并且是最新版本 包gd-devel-2.0.35-11.el6.x86_64已安装并且是最新版本 包libjpeg-turbo-1.2.1-3.el6_5.x86_64已安装并且是最新版本 包libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64已安装并且是最新版本 包libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64已安装并且是最新版本 无须任何处理 ]#yuminstalllibpnglibpng-devellibxml2-devellibcurl-devellibxslt-develzlibzlib-devel 依赖关系解决 ================================================================== 软件包架构版本仓库 =================================================================== 正在安装: libxml2-develx86_642.7.6-21.el6_8.1base libxslt-develx86_641.1.26-2.el6_3.1base 为依赖而安装: libgcrypt-develx86_641.4.5-12.el6_8base libgpg-error-develx86_641.7-4.el6base libxsltx86_641.1.26-2.el6_3.1base 为依赖而更新: libgcryptx86_641.4.5-12.el6_8base libxml2x86_642.7.6-21.el6_8.1base libxml2-pythonx86_642.7.6-21.el6_8.1base =================================================================== 包2:libpng-1.2.49-2.el6_7.x86_64已安装并且是最新版本 包2:libpng-devel-1.2.49-2.el6_7.x86_64已安装并且是最新版本 包libxml2-devel-2.7.6-21.el6_8.1.x86_64已安装并且是最新版本 包libcurl-devel-7.19.7-53.el6_9.x86_64已安装并且是最新版本 包libxslt-devel-1.1.26-2.el6_3.1.x86_64已安装并且是最新版本 包zlib-1.2.3-29.el6.x86_64已安装并且是最新版本 包zlib-devel-1.2.3-29.el6.x86_64已安装并且是最新版本 无须任何处理 ]#yuminstallopenldapopenldap-devel 依赖关系解决 ==================================================================== 软件包架构版本仓库 ==================================================================== 正在安装: openldap-develx86_642.4.40-16.el6base 正在升级: openldapx86_642.4.40-16.el6base 为依赖而安装: cyrus-sasl-develx86_642.1.23-15.el6_6.2base =================================================================== ]#yuminstalllibmcryptlibmcrypt-develmhashmcrypt#epel 依赖关系解决 ================================================================== 软件包架构版本仓库 =================================================================== 正在安装: libmcryptx86_642.5.8-9.el6epel libmcrypt-develx86_642.5.8-9.el6epel mcryptx86_642.6.8-10.el6epel mhashx86_640.9.9.9-3.el6epel ==================================================================
6.2 安装libiconv包(PHP版本5.5及以上内嵌)
]#yumlocalinstalllibiconv-1.15-1.x86_64.rpm 或 ]#tarxflibiconv-1.15.tar.gz ]#cdlibiconv-1.15 ]#./configure--prefix=/usr/local/libiconv ]#echo$? ]#make&&makeinstall ]#libtool--finish/usr/local/libiconv/lib ]#echo'/usr/local/libiconv/lib'>>/etc/ld.so.conf ]#cat/etc/ld.so.conf includeld.so.conf.d/*.conf /data/MysqL/lib /usr/local/libiconv/lib ]#ldconfig
6.3 编译安装PHP
]#cd/data/tools/ ]#tarxfPHP-5.6.31.tar.gz ]#cdPHP-5.6.31/ ]#./configure\ --prefix=/usr/local/PHP-5.6.31\ --enable-MysqLnd\ --with-MysqL=MysqLnd\ --with-MysqLi=MysqLnd\ --with-pdo-MysqL=MysqLnd\ --with-iconv-dir=/usr/local/libiconv\ --with-freetype-dir\ --with-jpeg-dir\ --with-png-dir\ --with-zlib\ --with-libxml-dir=/usr\ --with-ldap\ --enable-xml\ --disable-rpath\ --enable-bcmath\ --enable-shmop\ --enable-sysvsem\ --enable-inline-optimization\ --with-curl\ --enable-mbregex\ --enable-fpm\ --enable-mbstring\ --with-mcrypt\ --with-gd\ --with-gettext\ --enable-gd-native-ttf\ --with-openssl\ --with-mhash\ --enable-pcntl\ --enable-sockets\ --with-xmlrpc\ --enable-zip\ --enable-soap\ --enable-short-tags\ --enable-static\ --with-xsl\ --with-fpm-user=www\ --with-fpm-group=www\ --enable-opcache=no\ --enable-ftp ]#cp-frp/usr/lib64/libldap*/usr/lib/#报configure:error:Cannotfindldaplibrariesin/usr/lib.时执行 ]#echo$? 0 ]#make&&makeinstall ]#cp/data/tools/PHP-5.6.31/PHP.ini-production/usr/local/PHP-5.6.31/lib/PHP.ini ]#ln-s/usr/local/PHP-5.6.31/usr/local/PHP ]#cp/usr/local/PHP/etc/PHP-fpm.conf.default/usr/local/PHP/etc/PHP-fpm.conf
6.4 配置
查看PHP模块 ]#/usr/local/PHP/bin/PHP-m [PHPModules] bcmath Core ctype curl date dom ereg fileinfo filter ftp gd gettext hash iconv json ldap libxml mbstring mcrypt mhash MysqL MysqLi MysqLnd openssl pcntl pcre PDO pdo_MysqL pdo_sqlite Phar posix Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvsem tokenizer xml xmlreader xmlrpc xmlwriter xsl zip zlib [ZendModules] 修改PHP配置文件 ]#egrep-n"^post_max_size|^max_execution_time|^max_input_time|^date.timezone|^always_populate_raw_post_data"/usr/local/PHP/lib/PHP.ini 372:max_execution_time=30 382:max_input_time=60 660:post_max_size=8M ]#sed-i's#max_execution_time=30#max_execution_time=300#;s#max_input_time=60#max_input_time=300#;s#post_max_size=8M#post_max_size=16M#;s#;always_populate_raw_post_data=-1#always_populate_raw_post_data=-1#;s#;date.timezone=#date.timezone=Asia/Shanghai#'/usr/local/PHP/lib/PHP.ini ]#egrep-n"^post_max_size|^max_execution_time|^max_input_time|^date.timezone|^always_populate_raw_post_data"/usr/local/PHP/lib/PHP.ini 372:max_execution_time=300 382:max_input_time=300 660:post_max_size=16M 702:always_populate_raw_post_data=-1 936:date.timezone=Asia/Shanghai
6.5 启动PHP
]#/usr/local/PHP/sbin/PHP-fpm-t ]#/usr/local/PHP/sbin/PHP-fpm
7.源码安装zabbix(3.4.2)
7.1 依赖包
]#yuminstallnet-snmpnet-snmp-develfpingunixODBC-developenssl-develOpenIPMI-devellibeventlibevent-develpcre-devel 依赖关系解决 ================================================================== 软件包架构版本仓库 ================================================================== 正在安装: OpenIPMI-develx86_642.0.16-14.el6base fpingx86_642.4b2-10.el6epel libeventx86_641.4.13-4.el6base libevent-develx86_641.4.13-4.el6base net-snmpx86_641:5.5-60.el6base net-snmp-develx86_641:5.5-60.el6base unixODBC-develx86_642.2.14-14.el6base 为依赖而安装: OpenIPMIx86_642.0.16-14.el6base OpenIPMI-libsx86_642.0.16-14.el6base elfutils-develx86_640.164-2.el6base elfutils-libelf-develx86_640.164-2.el6base file-develx86_645.04-30.el6base libevent-docnoarch1.4.13-4.el6base libevent-headersnoarch1.4.13-4.el6base lm_sensors-develx86_643.1.1-17.el6base lm_sensors-libsx86_643.1.1-17.el6base ncurses-develx86_645.7-4.20090207.el6base net-snmp-libsx86_641:5.5-60.el6base popt-develx86_641.13-7.el6base rpm-develx86_644.8.0-55.el6base tcp_wrappers-develx86_647.6-58.el6base unixODBCx86_642.2.14-14.el6base ====================================================================
7.2 安装
]#useraddzabbix-s/sbin/nologin ]#cd/data/tools/ ]#tarxfzabbix-3.4.2.tar.gz ]#cdzabbix-3.4.2 ]#./configure--prefix=/usr/local/zabbix-3.4.2--enable-server--enable-agent--enable-java--with-MysqL--enable-ipv6--with-net-snmp--with-libcurl--with-libxml2--with-openipmi--with-unixodbc--with-openssl ]#ln-s/usr/local/MysqL/lib/libMysqLclient.so/usr/lib#报错时执行:configure:error:NotfoundMysqLclientlibrary ]#echo$? 0 ]#make&&makeinstall#如果报错:../../../include/zbxdb.h:65:20:error:MysqL.h:Nosuchfileordirectory;说明:zabbix编译时找不到MysqL.h文件,请卸载系统自带的MysqL,或安装MysqL-devel包 ]#ln-s/usr/local/zabbix-3.4.2/usr/local/zabbix
7.3 导入数据库
]#cd/data/tools/zabbix-3.4.2/database/MysqL ]#MysqL-uzabbix-p<password>zabbix<schema.sql ]#MysqL-uzabbix-p<password>zabbix<images.sql ]#MysqL-uzabbix-p<password>zabbix<data.sql ]#ln-s/usr/local/zabbix/etc//etc/zabbix ]#ln-s/usr/local/zabbix/bin/*/usr/bin/ ]#ln-s/usr/local/zabbix/sbin/*/usr/sbin/
7.4 拷贝启动脚本
]#cd/data/tools/zabbix-3.4.2/misc/init.d/fedora/core ]#cpzabbix_*/etc/init.d/
7.5 修改启动文件
]#sed-i"s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g"/etc/init.d/zabbix_server ]#sed-i"s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g"/etc/init.d/zabbix_agentd
7.6 修改zabbix服务端配置文件
]#egrep-v'^$|#'/etc/zabbix/zabbix_server.conf LogFile=/tmp/zabbix_server.log DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=<password>#数据库中zabbix用户的密码 DBSocket=/data/MysqL/MysqL.sock Timeout=4 LogSlowQueries=3000
7.7 修改zabbix客户端配置文件
]#egrep-v'^$|#'/etc/zabbix/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.log Server=127.0.0.1#被动模式中服务端或代理端的IP地址 ServerActive=127.0.0.1#主动模式中服务端或代理端的IP地址 Hostname=zabbix#当前客户端所在服务器的主机名;
7.8 复制zabbix站点到Nginx站点目录
]#cp-a/data/tools/zabbix-3.4.2/frontends/PHP/usr/local/Nginx/html/zabbix
7.9 站点授权
]#chown-Rwww.www/usr/local/Nginx/html/zabbix
7.10 启动zabbix服务
]#servicezabbix_serverstart#启动zabbix服务端 ]#ss-tnl|grep10051 ]#servicezabbix_agentdstart#启动zabbix客户端 ]#ss-tnl|grep10050
7.11 访问zabbix
http://192.168.1.92/zabbix 第一步:您应该看到前端安装向导的第一个屏幕; 第二步:确保满足PHP所有软件先决条件; 第三步:输入连接到数据库的详细信息。必须已经创建了Zabbix数据库并授权; 数据库类型:MysqL host:localhost#不行的话,可以尝试:127.0.0.1 port:0#0表示默认 DBname:zabbix#库名称 user:zabbix#MysqL用户 password:密码#MysqL普通用户密码 第四步:输入Zabbix服务器详细信息; 第五步:查看设置摘要; 第六步:完成安装;安装后生成的配置文件:/usr/local/Nginx-1.13.6/html/zabbix/conf/zabbix.conf.PHP 第七步:Zabbix前端准备好了!默认用户名为:Admin,密码:zabbix;
7.12 zabbix客户端:其它主机采用rpm安装
]#yuminstallzabbix-agentzabbix-sender ]#vim/etc/zabbix/zabbix_agentd.conf(3个*号开头的必须配置) ####Passivechecksrelated(被动检测相关的配置:agent等待server过来请求数据) *Server=127.0.0.1 #定义了被动模式中服务端或代理端的IP地址,多个用逗号隔开授权给哪些zabbix-server或zabbix-proxy过来采集数据的服务器地址列表; ListenPort=10050 ListenIP=0.0.0.0#本机的所有地址; StartAgents=3#agent进程数量; ####Activechecksrelated(主动检测相关的配置:agent主动向server发送监控数据) *ServerActive=IP[:Port] #定义了主动模式中服务端或代理端的IP地址,多个用逗号隔开,当前agent主动发送监控数据到server端; *Hostname=HOSTNAME#当前客户端所在服务器的主机名; 或 ]#sed-i's#^Server=127.0.0.1#Server=192.168.20.59#g;s#^ServerActive=127.0.0.1#ServerActive=192.168.20.59#g'/etc/zabbix/zabbix_agentd.conf#zabbix服务端不改, ]#sed-i"s#Hostname=Zabbixserver#Hostname=`hostname`#g"/etc/zabbix/zabbix_agentd.conf ]#egrep-v"^$|#"/etc/zabbix/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.log Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=zabbix
启动服务:
]#servicezabbix-agentstart ]#servicezabbix-agentstatus ]#ss-tnl|grep:10050 ]#iptables-vnL#防火墙没有阻断10050端口;
8.中文乱码
]#yuminstallwqy-microhei-fonts-y ]#cp/usr/share/fonts/wqy-microhei/wqy-microhei.ttc/usr/local/Nginx/html/zabbix/fonts/DejaVuSans.ttf 或 把win系统里的楷体常规上传到服务器上:C:\Windows\Fonts\simkai.ttf ]#cd/usr/local/Nginx/html/zabbix/fonts ]#rzsimkai.ttf ]#mvDejaVuSans.ttfDejaVuSans.ttf.bak ]#mvsimkai.ttfDejaVuSans.ttf ]#chown-Rwww.www* ]#ll 总用量12252 -rw-r--r--1wwwwww117851847月172016DejaVuSans.ttf -rw-r--r--1wwwwww7560729月2522:17DejaVuSans.ttf.bak
9.附
警告 PHPgettextoffWarning 两种方法:
9.1. 重新编译加上 --with-gettext
9.2. 添加PHP动态扩展库
进入PHP源码包ext目录下我们会发现有个gettext模块 执行如下命令 /usr/local/PHP-5.6.31/bin/PHPize#/usr/local/PHP-5.6.31/PHP安装路径 ./configure--with-PHP-config=/usr/local/PHP-5.6.31/bin/PHP-config make&&makeinstall /usr/local/PHP-5.6.31/lib/PHP.ini#根据自己系统安装路径而定 在PHP.ini里添加上gettext.so echo"extension=gettext.so">>/usr/local/PHP/lib/PHP.ini 缺少MysqLi同理 --with-MysqLi=/usr/local/MysqL/bin/MysqL_config echo"extension=MysqLi.so">/usr/local/PHP/lib/PHP.ini 查看PHP已经编译的模块 /usr/local/PHP/bin/PHP-m原文链接:https://www.f2er.com/centos/374516.html