您的位置:首页 > 运维架构 > Nginx

centos7安装zabbix3.2,Nginx+PHP+MySQL

2017-06-26 17:04 519 查看
1、centos7最小化安装,登录后设置ipvi /etc/sysconfig/network-scripts/ifcfg-ens33#####################################################TYPE=EthernetBOOTPROTO=noneDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens33UUID=e7837e36-33a7-47c8-a3b3-f4d705614eb3DEVICE=ens33ONBOOT=yesIPADDR=192.168.246.88GATEWAY=192.168.246.2NETMASK=255.255.255.0DNS1=114.114.114.114###################################################2、更新yum源,并更新系统yum install wget vim -ymv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repoyum update3、安装支持库yum install lsof mariadb mariadb-server mysql-devel lrzsz pcre-devel zlib-devel gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel libmcrypt libmcrypt-devel mcrypt mhash net-snmp-devel -y4、关闭防火墙和selinuxsystemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动setenforce 05、安装nginxmkdir /toolscd /toolswget http://nginx.org/download/nginx-1.11.3.tar.gztar -zxvf nginx-1.11.3.tar.gzcd nginx-1.11.3./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcremakemake install配置启动文件vim /etc/init.d/nginx#################################################vim /etc/init.d/nginx#!/bin/bash# chkconfig: - 30 21# description: http service.# Source Function Library. /etc/init.d/functions# Nginx Settings NGINX_SBIN="/usr/local/nginx/sbin/nginx"NGINX_CONF="/usr/local/nginx/conf/nginx.conf"NGINX_PID="/usr/local/nginx/logs/nginx.pid"RETVAL=0prog="Nginx" start() { echo -n $"Starting $prog: " mkdir -p /dev/shm/nginx_temp daemon $NGINX_SBIN -c $NGINX_CONF RETVAL=$? echo return $RETVAL} stop() { echo -n $"Stopping $prog: " killproc -p $NGINX_PID $NGINX_SBIN -TERM rm -rf /dev/shm/nginx_temp RETVAL=$? echo return $RETVAL} reload(){ echo -n $"Reloading $prog: " killproc -p $NGINX_PID $NGINX_SBIN -HUP RETVAL=$? echo return $RETVAL} restart(){ stop start} configtest(){ $NGINX_SBIN -c $NGINX_CONF -t return 0} case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; configtest) configtest ;; *) echo $"Usage: $0 {start|stop|reload|restart|configtest}" RETVAL=1esac exit $RETVAL###############################################编辑nginx配置文件: ################################################################user nobody nobody;worker_processes 2;error_log /usr/local/nginx/logs/nginx_error.log crit;pid /usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200; events{ use epoll; worker_connections 6000;} http{ include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096; log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]' '$host "$request_uri" $status' '"$http_referer" "$http_user_agent"'; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path /usr/local/nginx/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml; server{ listen 85; server_name localhost; index index.html index.htm index.php; root /usr/local/nginx/html; location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; } } }##############################################################################################检查语法:/usr/local/nginx/sbin/nginx -tservice nginx start #启动nginx6、安装phpuseradd -s /sbin/nologin php-fpmcd /tools/wget http://cn2.php.net/distributions/php-7.0.10.tar.gztar -zxvf php-7.0.10.tar.gzcd php-7.0.10./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --enable-bcmath --enable-mbstring --enable-sockets --with-gd --with-libxml-dir=/usr/local --with-gettext报错处理解决办法一
1、安装第三方yum源
wget http://www.atomicorp.com/installers/atomic sh ./atomic
2、使用yum命令安装
yum install php-mcrypt libmcrypt libmcrypt-devel
解决办法二、
使用php mcrypt 前必须先安装Libmcryptlibmcrypt源码安装方法:
1234567cd /usr/local/srcwget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gztar -zxvf libmcrypt-2.5.8.tar.gzcd /usr/local/src/libmcrypt-2.5.8./configure --prefix=/usr/localmakemake install
makemake installcp php.ini-production /usr/local/php/etc/php.inised -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /usr/local/php/etc/php.inised -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /usr/local/php/etc/php.inised -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /usr/local/php/etc/php.inised -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /usr/local/php/etc/php.ini配置php-fpm.confvim /usr/local/php/etc/php-fpm.conf###########################################################[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /usr/local/php/var/log/php-fpm.log[www]listen = /tmp/php-fcgi.sockuser = php-fpmgroup = php-fpmlisten.owner = nobodylisten.group = nobodypm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024####################################################检查语法/usr/local/php/sbin/php-fpm -t启动php/usr/local/php/sbin/php-fpmvim /etc/init.d/phpdphp启动脚本################################################ ######################################################################加权限并启动服务 vim /usr/local/nginx/html/2.php内容如下:<?php echo phpinfo();?>7、下载zabbix编译包:cd /tools/wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.3/zabbix-3.2.3.tar.gzgroupadd zabbixuseradd -g zabbix zabbixtar zxf zabbix-3.2.3.tar.gzcd zabbix-3.2.3./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2makemake installmkdir -p /usr/local/nginx/html/zabbixcp -ra frontends/php/* /usr/local/nginx/html/zabbix8、配置数据库mysql -urootcreate database zabbix character set utf8;grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';delete from mysql.user where user=""; flush privileges; mysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/schema.sqlmysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/images.sqlmysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/data.sql vim /usr/local/zabbix/etc/zabbix_server.conf###########################################LogFile=/tmp/zabbix_server.logDBHost=127.0.0.1DBName=zabbixDBUser=zabbixDBPassword=zabbixDBSocket=/var/lib/mysql/mysql.sockTimeout=4LogSlowQueries=3000#############################################[root@xuegod64 ~]# vim /usr/local/zabbix/etc/zabbix_server.confDBHost=localhost #默认注释掉了,直接取消注释即可DBName=zabbix #数据库用户,我们授权的用户也是zabbixDBUser=zabbix #默认是root,我们授权的用户是zabbixDBPassword=zabbix #密码我们授权的也是zabbix监控Zabbix Server本身监控本身,意思是本身作为服务器之外,自己也做自己的客户端,也要使用agentd这个代理者配置文件中,有agentd和agent两个配置文件,前者是守护进程,后者依赖xinetd[root@xuegod64 ~]# vim /usr/local/zabbix/etc/zabbix_agentd.confServer=127.0.0.1 #默认监控服务器自己,这三行不用改ServerActive=127.0.0.1Hostname=Zabbix serverUnsafeUserParameters=1 #允许所有的字符是在用户定义的参数,参数传递,也就是支持自定义脚本其中Server和ServerActive都指定zabbixserver的IP地址,不同的是,前者是被动后者是主动。也就是说前者允许127.0.0.1这个ip来我这取数据。而serverActive的127.0.0.1的意思是,客户端主动提交数据给他。启动服务[root@xuegod64 ~]# useradd -u 8005 -M -s /sbin/nologin zabbix//如果zabbix用户不存在,将以root运行,新建之后,如果zabbix存在,那么久直接可以用zabbix运行[root@xuegod64 ~]# /usr/local/zabbix/sbin/zabbix_server //直接运行[root@xuegod64 ~]# echo /usr/local/zabbix/sbin/zabbix_server >> /etc/rc.local //开机启动[root@xuegod64 ~]# netstat -antup | grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 94837/zabbix_serverbix_server
WEB访问: http://IP/zabbix 进入初始配置向导:
下一步
设置数据库连接信息,下一步
Mysql
Localhost
0是使用默认端口
Zabbix
Zabbix
123456
设置zabbix服务信息,下一步
主机ip:localhost
端口号:可以按照自己的需要设置
服务名称:yunvn
有可能会提示Unable to create the configuration file.
Please install it manually, or fix permissions on the conf directory.
Press the "Download configuration file" button, download the configuration file and save it as
"/home/wwwroot/php/conf/zabbix.conf.php"
直接下载zabbix.conf.php放到/home/wwwroot/php/conf/下就好了,或者修改/home/wwwroot/php/conf/的权限
Zabbix前端是准备好了!默认的用户名是Admin,密码zabbix
Ok,到此已安装成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Nginx centos7 zabbix3.2