Centos7一键编译安装LNMP脚本

#!/bin/bash

#具体版本号
NGINX_V=1.20.0
PHP_V=7.4.2
MYSQL_V=5.7.37
TMP_DIR=/tmp 
INSTALL_DIR=/usr/local

function install_nginx() {
#下载依赖
    yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel
    #安装配置
    #下载Nginx
    cd ${TMP_DIR}
    yum install -y wget && wget -c wget http://nginx.org/download/nginx-${NGINX_V}.tar.gz
    #解压源码
    tar -zxvf ${TMP_DIR}/nginx-${NGINX_V}.tar.gz
    mv nginx-${NGINX_V} nginx;cd nginx;
    #预编译配置
    ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
    sleep 2s
    #编译安装
    make && make install
    #以服务启动
    cd /usr/lib/systemd/system;
    cat > nginx.service < my.cnf < Nginx信息 <========="
    echo "      Nginx : $NGINX_V         "
    echo "    安装目录: /usr/local/ "
        
    echo "=========> MYSQL信息 <========="
    echo " 数据库版本 : 5.7.37           "
    echo " 数据库密码 : [email protected]        "
    echo " 数据库端口 : 3306             "
    echo " BASEDIR目录: /usr/local/mysql "
    echo " DATADIR目录: /data/mysql      "

    echo "==========> PHP信息 <=========="
    echo "   PHP版本 : $PHP_V            "
    echo "  安装目录 : /usr/local/       "
}

function main(){
    install_nginx
    install_mysql
    install_php
    install_info
}
main

你可能感兴趣的:(shellcentos)