1、centos7最小化安装,登录后设置ip
vi /etc/sysconfig/network-scripts/ifcfg-ens33
#####################################################
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=e7837e36-33a7-47c8-a3b3-f4d705614eb3
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.246.88
GATEWAY=192.168.246.2
NETMASK=255.255.255.0
DNS1=114.114.114.114
###################################################
2、更新yum源,并更新系统
yum install wget vim -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum update
3、安装支持库
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 -y
4、关闭防火墙和selinux
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
setenforce 0
5、安装nginx
mkdir /tools
cd /tools
wget http://nginx.org/download/nginx-1.11.3.tar.gz
tar -zxvf nginx-1.11.3.tar.gz
cd 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-pcre
make
make 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=0
prog="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=1
esac
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 -t
service nginx start #启动nginx
6、安装php
useradd -s /sbin/nologin php-fpm
cd /tools/
wget http://cn2.php.net/distributions/php-7.0.10.tar.gz
tar -zxvf php-7.0.10.tar.gz
cd 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 前必须先安装Libmcrypt
libmcrypt源码安装方法:
1 2 3 4 5 6 7 | cd /usr/local/src wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz tar -zxvf libmcrypt-2.5.8.tar.gz cd /usr/local/src/libmcrypt-2.5.8 ./configure --prefix=/usr/local make make install |
make
make install
cp php.ini-production /usr/local/php/etc/php.ini
sed -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /usr/local/php/etc/php.ini
sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /usr/local/php/etc/php.ini
sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /usr/local/php/etc/php.ini
sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /usr/local/php/etc/php.ini
配置php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
###########################################################
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
####################################################
检查语法
/usr/local/php/sbin/php-fpm -t
启动php
/usr/local/php/sbin/php-fpm
vim /etc/init.d/phpd
php启动脚本
################################################
######################################################################
加权限并启动服务
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.gz
groupadd zabbix
useradd -g zabbix zabbix
tar zxf zabbix-3.2.3.tar.gz
cd zabbix-3.2.3
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make
make install
mkdir -p /usr/local/nginx/html/zabbix
cp -ra frontends/php/* /usr/local/nginx/html/zabbix
8、配置数据库
mysql -uroot
create 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.sql
mysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix -h127.0.0.1 zabbix < database/mysql/data.sql
vim /usr/local/zabbix/etc/zabbix_server.conf
###########################################
LogFile=/tmp/zabbix_server.log
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Timeout=4
LogSlowQueries=3000
#############################################
[root@xuegod64 ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBHost=localhost #默认注释掉了,直接取消注释即可
DBName=zabbix #数据库用户,我们授权的用户也是zabbix
DBUser=zabbix #默认是root,我们授权的用户是zabbix
DBPassword=zabbix #密码我们授权的也是zabbix
监控Zabbix Server本身
监控本身,意思是本身作为服务器之外,自己也做自己的客户端,也要使用agentd这个代理者
配置文件中,有agentd和agent两个配置文件,前者是守护进程,后者依赖xinetd
[root@xuegod64 ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1 #默认监控服务器自己,这三行不用改
ServerActive=127.0.0.1
Hostname=Zabbix server
UnsafeUserParameters=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_server
bix_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,到此已安装成功。
共同学习,写下你的评论
评论加载中...
作者其他优质文章