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 80;

    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

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 /tools/zabbix-3.2.3/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/p_w_picpaths.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

#############################################