JeeSite 4.0測試環境搭建
需求:
jdk 1.8
Maven 3.3.0+
MySql 5.7.11+
tomcat 8
環境Linux 7.5
軟體包下載地址:
jdk-8u181-linux-x64.tar.gz
百度雲連結:https://pan.baidu.com/s/16BpipO0eVTe8a0A43-Y9fA 密碼:1s8l
apache-maven-3.5.3-bin.tar.gz
百度雲連結:https://pan.baidu.com/s/1p8K1vejoP4FtGIuex-_QUg 密碼:t71e
mysql-5.7.11-1.el7.x86_64.rpm-bundle.tar
百度雲連結:https://pan.baidu.com/s/1zKoDH-zLNJJuOSmBqMkdXA 密碼:gsl3
apache-tomcat-8.0.30.tar.gz
百度雲連結:https://pan.baidu.com/s/10qkqR_HMwV4xnpOLQEHF9Q 密碼:rnmy
步驟:
解壓jdk1.8
tar xf jdk-8u181-linux-x64.tar.gz -C /usr/local/
解壓maven
tar xf apache-maven-3.5.3-bin.tar.gz -C /usr/local/
解壓tomcat8
tar xf apache-tomcat-8.0.30.tar.gz -C /usr/local/
設定環境變數:
vim /etc/profile
#JAVA_HOME
export JAVA_HOME=/usr/local/jdk1.8.0_181
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
#MAVEN
export MAVEN_HOME=/usr/local/apache-maven-3.5.3
export PATH=$MAVEN_HOME/bin:$PATH
儲存退出
source /etc/profile (重新整理載入配置檔案)
驗證是否生效:
java -version
mvn -v
啟動tomcat:
/usr/local/apache-tomcat-8.0.30/bin/startup.sh
開啟網頁: IP:8080 (tomcat是否成功)(如雲伺服器,記得開啟安全組埠)
安裝資料庫:
https://blog.csdn.net/qq_33663251/article/details/54693201
匯入JeeSite 4.0原始碼:
git clone https://gitee.com/thinkgem/jeesite4.git
修改mysql連線配置檔案。(因這環境都在一個機器上,使用預設即可)
jeesite4/web/src/main/resources/config(配置檔案位置)
執行打war包:
cd jeesite4/web/bin/
chmod +x package.sh
./package.sh
檢視打包
將war包放進tomcat8裡
驗證 ip:8080/web
自己寫的自動更新拉取程式碼的指令碼(利用crontab,某個時間檢測程式碼。或用jenkins也可實現)
#!/bin/bash
#自動更新war包指令碼
#git ssh協議獲取程式碼
#/teachLab_server專案git路徑資料夾
#/web_backup,war包備份路徑
#teachLab_server專案分支,拉取程式碼,存在則跳過
cd /teachLab_server/
if [ ! -d /teachLab_server/teachLab_server/ ];then
/usr/bin/git clone [email protected]專案地址
#執行打war包命令
cd /teachLab_server/teachLab_server/jeesite4/web/bin
/usr/bin/chmod +x ./package.sh
./package.sh
#關閉tomcat
/usr/bin/killall -9 java
/usr/bin/killall -9 java
/usr/bin/killall -9 java
#打包舊的web專案檔案,備份
if [ -d /usr/local/tomcat8/webapps/web ];then
cd /usr/local/tomcat8/webapps/
/usr/bin/tar -cvf /web_backup/`date +%F_%Hh_%Mm`.tar.gz ./web
#刪除4天前的備份
find /web_backup/ -mtime +3 -exec rm -rf {} \;
fi
#刪除舊的專案程式碼
rm -rf /usr/local/tomcat8/webapps/web/META-INF/
rm -rf /usr/local/tomcat8/webapps/web/org
rm -rf /usr/local/tomcat8/webapps/web/WEB-INF
#將新的war包解壓
cd /teachLab_server/teachLab_server/jeesite4/web/target/
/usr/local/jdk1.8.0_181/bin/jar xf web.war
#將新程式碼mv到tomcat上
mv ./META-INF ./org ./WEB-INF /usr/local/tomcat8/webapps/web/
#啟動tomcat
/usr/local/tomcat8/bin/startup.sh
cd /usr/local/tomcat8/bin
./startup.sh
#重啟tomcat
/jiaoben/tomcatstart.sh
#刪除打包後的資料夾
rm -rf /teachLab_server/teachLab_server/jeesite4/web/target
fi
#git更新程式碼,如沒有更新則跳過
cd /teachLab_server/teachLab_server/
A=`git pull | awk '{print $1}'`
if [ "$A" = Already ];then
echo '沒有新的程式碼更新'
else
#更新程式碼
/usr/bin/git pull
#執行打war包命令
cd /teachLab_server/teachLab_server/jeesite4/web/bin
/usr/bin/chmod +x ./package.sh
./package.sh
#關閉tomcat
/usr/bin/killall -9 java
/usr/bin/killall -9 java
/usr/bin/killall -9 java
#打包舊的web專案檔案,備份
if [ -d /usr/local/tomcat8/webapps/web ];then
cd /usr/local/tomcat8/webapps/
/usr/bin/tar -cvf /web_backup/`date +%F_%Hh_%Mm`.tar.gz ./web
#刪除4天前的備份
find /web_backup/ -mtime +3 -exec rm -rf {} \;
fi
#刪除舊的專案程式碼
rm -rf /usr/local/tomcat8/webapps/web/META-INF/
rm -rf /usr/local/tomcat8/webapps/web/org
rm -rf /usr/local/tomcat8/webapps/web/WEB-INF
#將新的war包解壓
cd /teachLab_server/teachLab_server/jeesite4/web/target/
/usr/local/jdk1.8.0_181/bin/jar xf web.war
#將新程式碼mv到tomcat上
mv ./META-INF ./org ./WEB-INF /usr/local/tomcat8/webapps/web/
#啟動tomcat
/usr/local/tomcat8/bin/startup.sh
cd /usr/local/tomcat8/bin
./startup.sh
#重啟tomcat
/jiaoben/tomcatstart.sh
#刪除打包後的資料夾
rm -rf /teachLab_server/teachLab_server/jeesite4/web/target
fi
(指令碼是更新程式碼,打包war包,將war包裡的程式碼解壓,換成tomcat裡新的程式碼。)
(避免直接刪除web檔案,導致專案裡的本地資料消失)