此脚本是LNMP环境搭建Zabbix监控平台自动化安装脚本,有需要朋友可以参考,脚本内容如下:
系统环境:CentOS 7.4
软件版本:
Nginx:1.16.1
Mysql:5.7.29
PHP:7.3.7
Zabbix:4.4.3
[root@localhost ~]# vim auto_install_lnmp_zabbix.sh
代码语言:javascript复制#!/bin/bash
#Date:2018-5-20 14:08:55
#Author Blog:
# https://www.yangxingzhen.com
#Author WeChat:
#Author mirrors site:
# https://mirrors.yangxingzhen.com
#About the Author
# BY:YangXingZhen
# Mail:xingzhen.yang@yangxingzhen.com
#Auto Install LNMP Environment And Zabbix
source /etc/rc.d/init.d/functions
#Define Nginx path variables
NGINX_URL=http://nginx.org/download
NGINX_FILE=nginx-1.16.1.tar.gz
NGINX_FILE_DIR=nginx-1.16.1
NGINX_PREFIX=/usr/local/nginx
#Define Boost path variables
Boost_URL=https://mirrors.yangxingzhen.com/mysql
Boost_File=boost_1_59_0.tar.gz
#Define Mysql path variables
MYSQL_URL=http://mirrors.163.com/mysql/Downloads/MySQL-5.7
MYSQL_FILES=mysql-5.7.29.tar.gz
MYSQL_FILES_DIR=mysql-5.7.29
MYSQL_PREFIX=/usr/local/mysql
MYSQL_DIR=/data/mysql
MYSQL_USER=mysql
#Define ZIP path variables
ZIP_URL=https://nih.at/libzip
ZIP_FILE=libzip-1.2.0.tar.gz
ZIP_FILE_DIR=libzip-1.2.0
#Define PHP path variables
PHP_URL=http://mirrors.sohu.com/php
PHP_FILE=php-7.3.7.tar.gz
PHP_FILE_DIR=php-7.3.7
PHP_PREFIX=/usr/local/php
USER=www
#Define Zabbix path variables
ZABBIX_URL=http://mirrors.yangxingzhen.com/zabbix
ZABBIX_FILES=zabbix-4.4.3.tar.gz
ZABBIX_FILES_DIR=zabbix-4.4.3
ZABBIX_PREFIX=/usr/local/zabbix
function Install_Nginx() {
#Install Nginx Soft
if [ ! -d ${NGINX_PREFIX} ];then
yum -y install pcre pcre-devel openssl openssl-devel gcc gcc-c wget
wget -c ${NGINX_URL}/${NGINX_FILE}
tar zxf ${NGINX_FILE}
cd ${NGINX_FILE_DIR}
sed -i 's/1.16.1/ /;s/nginx//nginx/' src/core/nginx.h
useradd -s /sbin/nologin www
./configure --prefix=${NGINX_PREFIX}
--user=www
--group=www
--with-http_ssl_module
--with-http_stub_status_module
if [ $? -eq 0 ];then
make && make install
action "NGINX Install Success..." /bin/true
else
action "NGINX Install Failed..." /bin/false
exit 1
fi
else
echo -e "