一、脚本的环境介绍
此脚本运行在RHEL(CentOS)6.4版本及以上
运行此脚本需注意:
1、主机需要能够上网
2、需了解软件之间的相互依赖性。
二、脚本的介绍
脚本是由函数组成,每一个函数实现一个功能,采用select菜单显示 case
三、脚本的功能介绍
1、支持某台机器单独安装某一个软件,如Nginx、Mysql、PHP
2、支持某台机器一键安装LNMP环境
3、如果想一个一个的安装LNMP架构,请注意安装顺序:Nginx–>Mysql–>PHP
4、会自行的把服务开启,并加入到开机自动启动的服务列表中
LAMP自动化安装脚本代码
代码语言:javascript复制#!/bin/bash
#About the Author
# BY:YangXingZhen
# Mail:xingzhen.yang@yangxingzhen.com
#Auto Install LAMP Environment
source /etc/rc.d/init.d/functions
#Define APR path variables
APR_URL=https://mirrors.yangxingzhen.com/apr
APR_FILES=apr-1.6.3.tar.gz
APR_FILES_DIR=apr-1.6.3
APR_PREFIX=/usr/local/apr
#Define APR-util path variables
APR_UTIL_URL=https://mirrors.yangxingzhen.com/apr-util
APR_UTIL_FILES=apr-util-1.6.1.tar.gz
APR_UTIL_FILES_DIR=apr-util-1.6.1
APR_UTIL_PREFIX=/usr/local/apr-util
#Define PCRE path variables
PCRE_URL=https://mirrors.yangxingzhen.com/pcre
PCRE_FILES=pcre-8.41.tar.gz
PCRE_FILES_DIR=pcre-8.41
PCRE_PREFIX=/usr/local/pcre
#Define Apache path variables
APACHE_URL=https://mirrors.yangxingzhen.com/apache
APACHE_FILES=httpd-2.4.28.tar.gz
APACHE_FILES_DIR=httpd-2.4.28
APACHE_PREFIX=/usr/local/apache
APACHE_INIT_FILE=/etc/init.d/httpd
#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 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=apache
#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
source /etc/rc.d/init.d/functions
function Install_Apache (){
#Install APR
if [ ! -d ${APR_PREFIX} ];then
yum -y install gcc gcc-c wget
cd ${HOME} && wget -c ${APR_URL}/${APR_FILES}
tar zxf ${APR_FILES}
cd ${APR_FILES_DIR}
./configure --prefix=${APR_PREFIX}
if [ $? -eq 0 ];then
make && make install
action "The APR Install Sussess..." /bin/true
else
aciton "The APR Install Failed..." /bin/false
exit 1
fi
else
echo -e "