#Server deployment—"Linux loads git warehouse code package and runs"
Summary:
Server configuration summary (linux) + (jdk) + (tomcat) + (mysql) + (nginx) + (redis) + (fastDFS) + (mycat)
Continued from the previous chapter:
Server deployment-"mycat"
Eight, git installation
# 安装git
yum install git
#完成后查看git版本
git version
Nine, maven installation
Installation package: apache-maven-3.6.1-bin.tar.gz
extraction code: 26ea
- create:
mkdir -p /opt/maven
- enter:
cd /opt/maven
- Upload:
- Unzip:
tar -zxvf apache-maven-3.6.1-bin.tar.gz
- edit:
vi /etc/profile
- Configure environment variables:
//进编辑模式
i
//文档最后添加:
export MAVEN_HOME=/opt/maven/apache-maven-3.6.1
export PATH=$MAVEN_HOME/bin:$PATH
//保存退出
ESC
:wq
//更新配置
source /etc/profile
Ten, shell script
echo "=====================删除原代码====================="
rm -rf /root/teacher_plus/
rm -rf /out/teacher_plus/
## 从git拉取代码
echo "=====================拉取新代码====================="
git clone https://gitee.com/idse666666/teacher_plus.git
mv -f /root/teacher_plus/ /out/teacher_plus/
cd /out/teacher_plus/
## 构筑项目
echo "=====================正在打包====================="
mvn clean install
## 关闭服务
echo "=====================正在关闭jar服务====================="
pid=`ps ax | grep -i 'jar' |grep java | grep -v grep | awk '{print $1}'`
if [ -z "$pid" ] ; then
echo "No $1 running."
else
echo "The $1(${pid}) is running..."
kill ${pid}
echo "Send shutdown request to $1(${pid}) OK"
fi
echo "=====================启动nginx==================="
/usr/local/nginx/sbin/nginx
echo "=====================启动ridis==================="
cd /opt/redis/redis-5.0.3/bin/
./redis-server redis.conf
## 启动服务
echo "=====================正在启动项目====================="
nohup java -jar /out/teacher_plus/target/teacher_plus-0.0.1-SNAPSHOT.jar >/out/project_log.out 2>&1 &
echo "=====================项目启动完毕====================="