所需安装包

fping-3.12.tar.gz
zabbix-3.2.1.tar.gz
libmcrypt-2.5.7.tar.gz
php-5.6.27.tar.gz
pcre-8.39.tar.gz
zlib-1.2.8.tar.gz
nginx-1.14.0.tar.gz
mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

字体包(宋体)

simkai.ttf

1、安装mysql

cd 

tar zxf  mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

groupadd -r mysql

useradd -r -g mysql -s /bin/false -M mysql

rpm -e mariadb-libs --nodeps

mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql

cd /usr/local/mysql/

mkdir data

chown -R mysql:mysql /usr/local/mysql/

ln -s /usr/local/mysql/bin/* /usr/local/bin

####vim /etc/my.cnf
	[client]
	socket=/usr/local/mysql/mysql.sock

	[mysqld]
	basedir=/usr/local/mysql
	datadir=/usr/local/mysql/data
	user=mysql
	pid-file=/usr/local/mysql/data/mysqld.pid
	log-error=/usr/local/mysql/data/mysql.err
	socket=/usr/local/mysql/mysql.sock
	port=3306
	
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

PASS=`cat /usr/local/mysql/data/mysql.err  | grep localhost | awk -F"localhost: " {'print $2'}`

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig on mysqld

systemctl daemon-reload

systemctl start mysqld

mysqladmin  -uroot -p$PASS password '123'

2、安装依赖包

yum -y install make apr* autoconf automake curl-devel gcc gcc-c++ openssl \
openssl-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel \
keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel \
zlib-devel libXpm* freetype libjpeg* libpng* libtool* libxml2 libxml2-devel patch libcurl-devel \
bzip2-devel freetype-devel

3、安装nginx

cd

tar zxf pcre-8.39.tar.gz

tar zxf zlib-1.2.8.tar.gz

tar zxf nginx-1.14.0.tar.gz

cd nginx-1.14.0

groupadd -r www

useradd -r - g www -s /sbin/nologin www

./configure --prefix=/usr/local/nginx --with-http_dav_module \
--with-http_stub_status_module --with-http_addition_module --with-http_sub_module \
--with-http_flv_module --with-http_mp4_module --with-pcre=/root/pcre-8.39 \
--with-zlib=/root/zlib-1.2.8 --with-http_ssl_module --with-http_gzip_static_module --user=www \
--group=www

make && make install

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/nginx

####vim /usr/local/nginx/conf/nginx.conf
	user www www;
	worker_processes 4;
	#error_log logs/error.log;
	#error_log logs/error.log notice;
	#error_log logs/error.log info;
	#pid logs/nginx.pid;
	events {
		use epoll;
		worker_connections 1024;
	}
	http {
	include mime.types;
		default_type application/octet-stream;
		#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
		# '$status $body_bytes_sent "$http_referer" '
		# '"$http_user_agent" "$http_x_forwarded_for"';
		#access_log logs/access.log main;
		sendfile on;
		#tcp_nopush on;
		#keepalive_timeout 0;
		keepalive_timeout 65;
		#gzip on;
		server {
		listen 80;
		server_name localhost;
		charset utf-8;
		#access_log logs/host.access.log main;
		location / {
			root html;
			index index.php index.html index.htm;
			}
		location ~ \.php$ {
			root html;
			fastcgi_pass 127.0.0.1:9000;
			fastcgi_index index.php;
			include fastcgi.conf;
			}
		#error_page 404 /404.html;
		# redirect server error pages to the static page /50x.html
		#
		error_page 500 502 503 504 /50x.html;
		location = /50x.html {
			root html;
			}
		location /status {
			stub_status on;
			}
		}
	}
	
nginx -t

nginx

4、安装php

cd

tar zxf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

./configure && make && make install

ln -s /usr/local/mysql/lib/libmysqlclient.so.20.3.9 /usr/local/mysql/lib/libmysqlclient_r.so

tar zxf php-5.6.27.tar.gz

cd php-5.6.27

./configure --prefix=/usr/local/php --with-config-file-path=/etc \
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/usr/local/mysql/mysql.sock --with-gd --with-iconv --with-libxml-dir=/usr \
--with-mhash --with-mcrypt --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib \
--with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop \
--enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring \
--enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc \
--enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt \
--with-curl

make && make install

cp php.ini-production /etc/php.ini

sed -i 's#;date.timezone =#date.timezone = PRC#g' /etc/php.ini

sed -i 's#expose_php = On#expose_php = Off#g' /etc/php.ini

sed -i 's#short_open_tag = Off#short_open_tag = On#g' /etc/php.ini

sed -i 's#post_max_size = 8M#post_max_size = 16M#g' /etc/php.ini

sed -i 's#max_execution_time = 30#max_execution_time = 300#g' /etc/php.ini

sed -i 's#max_input_time = 60#max_input_time = 300#g' 

sed -i 's#;always_populate_raw_post_data = -1#always_populate_raw_post_data = -1#g' /etc/php.ini

sed -i 's#;mbstring.func_overload = 0#mbstring.func_overload = 0#' /etc/php.ini

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

sed -i 's#;pid = run/php-fpm.pid#pid = run/php-fpm.pid#g' /usr/local/php/etc/php-fpm.conf

sed -i 's/listen = 127.0.0.1:9000/listen = 0.0.0.0:9000/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/pm.max_children = 5/pm.max_children = 300/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/pm.start_servers = 2/pm.start_servers = 10/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 10/g' /usr/local/php/etc/php-fpm.conf

sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 50/g' /usr/local/php/etc/php-fpm.conf

sed -i 's#user = nobody#user = www#g' /usr/local/php/etc/php-fpm.conf

sed -i 's#group = nobody#group = www#g' /usr/local/php/etc/php-fpm.conf

service php-fpm start

5、php和mysql测试页面

cat > /usr/local/nginx/html/test1.php << EOF

EOF

cat > /usr/local/nginx/html/test2.php << EOF

EOF

6、安装zabbix

yum -y install net-snmp net-snmp-devel curl-devel java-1.8.0-openjdk \
java-1.8.0-openjdk-devel OpenIPMI-devel libssh2-devel

groupadd zabbix

useradd -g zabbix -s /sbin/nologin zabbix

cd 

tar zxf fping-3.12.tar.gz

cd fping-3.12

./configure && make && make install

chown root:zabbix /usr/local/sbin/fping

chmod 4710 /usr/local/sbin/fping

tar zxf zabbix-3.2.1.tar.gz

cd zabbix-3.2.1

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent \
--enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl \
--with-openipmi

make && make install

ln -s /usr/local/zabbix/bin/* /usr/local/bin/

ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
mysql -uroot -p123

mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected, 1 warning (0.00 sec)
cd ~/zabbix-3.2.1/database/mysql/

mysql -uzabbix -pzabbix -hlocalhost zabbix < schema.sql 

mysql -uzabbix -pzabbix -hlocalhost zabbix < images.sql

mysql -uzabbix -pzabbix -hlocalhost zabbix < data.sql
mkdir -p /usr/local/zabbix/logs

chown -R zabbix:zabbix /usr/local/zabbix

####vim /usr/local/zabbix/etc/zabbix_server.conf
	LogFile=/usr/local/zabbix/logs/zabbix_server.log
	PidFile=/usr/local/zabbix/logs/zabbix_server.pid
	DBHost=localhost
	DBName=zabbix
	DBUser=zabbix
	DBPassword=zabbix
	DBPort=3306
	FpingLocation=/usr/local/sbin/fping
	DBSocket=/usr/local/mysql/mysql.sock
	
####vim /etc/ld.so.conf
	include ld.so.conf.d/*.conf
	/usr/local/mysql/lib
	/usr/local/lib
	
ldconfig
cd ~/zabbix-3.2.1/

cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server

chmod +x /etc/rc.d/init.d/zabbix_server
 
chkconfig --add zabbix_server

chkconfig zabbix_server on

####vim /etc/rc.d/init.d/zabbix_server
    ...
    BASEDIR=/usr/local/zabbix/ 
    PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid
        ...
	
systemctl daemon-reload

systemctl start zabbix_server
ss -lnpt|grep 10051
##应该可以过滤出来端口

6、防火墙规则

firewall-cmd --permanent --add-port=10051/tcp  

firewall-cmd --permanent --add-port=3306/tcp 

firewall-cmd --permanent --add-port=80/tcp

firewall-cmd --permanent --add-port=9000/tcp

firewall-cmd --reload

7、zabbix网页配置

cp -rf ~/zabbix-3.2.1/frontends/php/ /usr/local/nginx/html/zabbix
chown -R www:www /usr/local/nginx/html/
cd /usr/local/nginx/html/zabbix/fonts/
mv ~/simkai.ttf ./
####vim /usr/local/nginx/html/zabbix/include/locales.inc.php
	...
	'zh_CN' => ['name' =>_('Chinese (zh_CN)'), 'display' => true],
	...
	
	:% s/DejaVuSans.ttf/simkai.ttf/g

/usr/local/nginx/html/zabbix/include/locales.inc.php的修改

第一

'zh_CN' => ['name' =>_('Chinese (zh_CN)'), 'display' => true],

第二(使用s替换所有的DejaVuSans.ttf为simkai.ttf)

:% s/DejaVuSans.ttf/simkai.ttf/g

8、测试,直接访问http://ip地址/zabbix