Complete the initialization of ubuntu16.04 and the deployment of Java maven and docker environments in three minutes

  • 2021-09-11 21:54:29
  • OfStack

Fast-Linux Project Address: https://gitee.com/uitc/Fast-Linux

Introduction

The initialization of Linux and the construction of some common environments are simple but time-consuming tasks. In particular, your Linux went down due to some uncontrollable factors, which means that you have to deploy the environment again from scratch, which is a bit maddening. Therefore, I have the idea of building this Linux initialization script library. No matter Xiaobai or Big Brother, you only need to run with one button, and then have a cup of coffee, and the environment can be built successfully. Isn't it flattering?

Due to limited personal ability, I can only summarize the environment scripts I encountered (I am Java development, not familiar with python, c/c + +, etc.)

Because there are many versions of linux and various development environments, this is a warehouse that needs everyone's contribution to become more and more powerful. Welcome everyone to fork push start! ! !

Using tutorials

For the new Linux, make sure you are logged in as an root user. If not, please use sudo passwd root to set the initial password for your root, and then log in again Enter cd to enter the user directory (other directories are OK, it is recommended to put them in the user directory) to run git clone https://gitee.com/qiu-qian/Fast-Linux.git Cloning the project Enter your corresponding version of Linux system, for example, I am Ubuntu 16.04, then enter cd Fast-Linux/ubuntu/ubuntu16-04/ Follow the instructions to find the environment you want to deploy, and then set it as an executable file. For example, if I want to use start. sh, enter chmod 700 start.sh Just run the script. For example, if I want to use start. sh, enter ./start.sh Sit down and have a cup of coffee. .

Script update log

(Note: If you need to submit, please add it after the log, explaining the script path and environment combination you added, which is in a unified format and convenient for management)

2020/7/26

ubuntu/ubuntu16-04/start.sh Setting up the domestic Apt source Allow root users to log on remotely through ssh jdk-8u251 Environment apache-maven-3. 6.3 Environment (Alibaba Cloud maven Repository)

# Settings apt Source 
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiversec" >/etc/apt/sources.list

# Update apt Source 
apt-get update

# Allow root Users pass through ssh Telecontrol login 
sed -i "s/PermitRootLogin prohibit-password/#PermitRootLogin prohibit-password\nPermitRootLogin yes/g" /etc/ssh/sshd_config

# Restart ssh Services 
service ssh restart

# Append system commands to user variables to prevent restart commands from failing 
echo 'export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games' >>/etc/profile

# Create a new folder and assign resources 
mkdir /usr/local/java
mkdir /usr/local/maven
cp settings.xml /usr/local/maven

# Installation Java
cd /usr/local/java
# Download java Installation package 
curl -o jdk-8u251-linux-x64.tar.gz https://code.aliyun.com/kar/oracle-jdk/raw/3c932f02aa11e79dc39e4a68f5b0483ec1d32abe/jdk-8u251-linux-x64.tar.gz
tar -zxvf jdk-8u251-linux-x64.tar.gz
rm jdk-8u251-linux-x64.tar.gz
# Append java System environment variables of ( Available to all users )
echo 'export JAVA_HOME=/usr/local/java/jdk1.8.0_251' >>/etc/environment
echo 'export JRE_HOME=/usr/local/java/jdk1.8.0_251/jre' >>/etc/environment
echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >>/etc/environment
echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >>/etc/environment
# Append java User environment variables of 
echo 'export JAVA_HOME=/usr/local/java/jdk1.8.0_251' >>/etc/profile
echo 'export JRE_HOME=/usr/local/java/jdk1.8.0_251/jre' >>/etc/profile
echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >>/etc/profile
echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >>/etc/profile

# Installation maven
cd /usr/local/maven
# Download maven Installation package 
curl -o apache-maven-3.6.3-bin.tar.gz https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -zxvf apache-maven-3.6.3-bin.tar.gz
rm apache-maven-3.6.3-bin.tar.gz
# Append maven System environment variables of ( Available to all users )
echo 'export M2_HOME=/usr/local/maven/apache-maven-3.6.3' >>/etc/environment
echo 'export CLASSPATH=$CLASSPATH:$M2_HOME/lib' >>/etc/environment
echo 'export PATH=$PATH:$M2_HOME/bin' >>/etc/environment
# Append maven User environment variables of 
echo 'export M2_HOME=/usr/local/maven/apache-maven-3.6.3' >>/etc/profile
echo 'export CLASSPATH=$CLASSPATH:$M2_HOME/lib' >>/etc/profile
echo 'export PATH=$PATH:$M2_HOME/bin' >>/etc/profile
# New maven Warehouse 
mkdir repository
# Modify maven Configuration file for 
# rm apache-maven-3.6.3/conf/settings.xml
mv settings.xml apache-maven-3.6.3/conf

# Restart 
reboot
ubuntu/ubuntu16-04/docker.sh Install docker (domestic image) Installing docker-compose

#docker Environment build script 

# Download docker
curl -fsSL get.docker.com -o get-docker.sh
# sh get-docker.sh --mirror Aliyun
sh get-docker.sh --mirror AzureChinaCloud

# Configuring Mirror Acceleration 
echo "{\"registry-mirrors\": [\"https://qy5lms4s.mirror.aliyuncs.com\"]}" >/etc/docker/daemon.json
# Restart service 
systemctl daemon-reload
systemctl restart docker
# Pull ubuntu:16.04 Test 
docker pull ubuntu:16.04

#docker-compose Installation of 
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m) >/usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Related articles: