Centos 7 Install JDK+Maven+Git+MySql+Redis

1, first let’s create a new location to store our script directory

mkdir script
Copy the code

After executing, we have the script folder in our /home directory

Go to the file directory and put the script we wrote in advance into it

The above script files are these, let’s take a look at the script content and the execution effect.

1. Installation of JDK

JDK related scripts, the above script is very simple here will not be described too much

#! /bin/bash

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Install the JDK quickly
This was successfully verified in # CentOS7
# yum install
#
# author: Somnus_小 kay
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

hasJdk(){
    RESULT=$(pgrep java)
    if[[!$RESULT ]]
    then
        return 0;
    fi
    return 1;
}

hasJdk
if[$?!= 1]then
    echo "Not Found jdk"
    echo "Installing jdk..."Yum install -y java-1.8.0-openJDK hasJdkif[$?!= 1]then
      echo "Install jdk Fail"
    fi
fi

java -version
echo ""

Copy the code

Executing script commands

./install-jdk.sh
Copy the code

The JDK installation is complete

2. Maven installation

Maven scripts

#! /bin/bash

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Quickly install maven scripts
#
# author: Somnus_小 kay
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

hasMaven(){
    MAVEN_VERSION=$(mvn -version)
    echo "${MAVEN_VERSION}"
    if[[!$MAVEN_VERSION ]]
    then
        return 0;
    fi
    return 1;
}

hasMaven

if[$?!= 1]then
    echo "Not Found maven"
    echo "Installing maven..."

    Maven Aliyun Mirror Settings.xml
    wget -O settings.xml https://raw.githubusercontent.com/geekidea/spring-boot-plus/master/docs/config/settings.xml

    yum install -y maven

    hasMaven
    if[$? == 1]then
      echo "Config Aliyun Maven Mirror..."
      rm -rf /etc/maven/settings.xml
      cp settings.xml /etc/maven/
      mvn -version
    else
      echo "Install maven Fail"
    fi
fi

echo ""
Copy the code

Run the./install-maven.sh script

./install-maven.sh 
Copy the code

At this point, Maven execution ends

3. Git installation

Git related scripts

#! /bin/bash

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Install GIT quickly
This was successfully verified in # CentOS7
# yum install
#
# author: Somnus_小 kay
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

hasGit(){
    GIT_VERSION=$(git --version)
    echo "${GIT_VERSION}"
    if [[ $GIT_VERSION == *version* ]]
    then
        return 1;
    fi
    return 0;
}

hasGit

if[$?!= 1]then
    echo "Not Found Git"
    echo "Installing Git..."
    yum install -y git
    hasGit
    if[$?!= 1]then
      echo "Install Git Fail"
    fi
fi

echo "Git Success"

Copy the code

Run the./install-git.sh script

./install-git.sh
Copy the code

Git installation is complete

4. MySql installation

MySql script

#! /bin/bash

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Install MySQL quickly
This was successfully verified in # CentOS7
# yum+ RPM
#
# author: Somnus_小 kay
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

# Configure the ali yum mirror source first
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all

# update cache
yum makecache

Download mysql RPM
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

# RPM installation
rpm -Uvh mysql80-community-release-el7-3.noarch.rpm

# yum install mysql
yum install -y mysql-community-server

Start the mysql service
systemctl start mysqld.service

Check the mysql service status
systemctl status mysqld.service

The following command is omitted because of the server download. If you need it, you can add it in this script
Copy the code

Run the./install-mysql.sh script

./install-mysql.sh
Copy the code

This installation is a bit slow and needs to be patient

5, Redis installation

Redis script

#! /bin/bash

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Quickly install the Redis shell script
#
# author: Somnus_小 kay
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

hasRedis(){
    RESULT=$(redis-server -v)
    echo "${RESULT}"
    if[[!$RESULT ]]
    then
        return 0;
    fi
    return 1;
}

hasRedis

if[$?!= 1]then
    echo "Not Found redis"
    echo "Installing redis..."
    yum install -y redis
    hasRedis
    if[$?!= 1]then
      echo "Install Redis Fail"
    fi
fi

Set redis to boot upon startup
systemctl enable redis
Start the Redis service in the background
systemctl start redis
# Check whether the connection can be normal through redis-CLI and output PONG, then the connection is successful
redis-cli ping

echo ""

Copy the code

Run the./install-redis.sh script

./install-redis.sh
Copy the code

So far we have installed Redis

See how Easy it is to install via this script! Finally we execute by merging our scripts.

#! /bin/bash

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Execute related scripts in full installation sequence
#
# author: Somnus_ kai
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
sh install-jdk.sh
sh install-maven.sh
sh install-git.sh
sh install-mysql.sh
sh install-redis.sh

Copy the code

End: If it helps you, please click “like” and share it with your friends.