Tomcat 方式部署 Solo 博客系统总结
??此篇為Tomcat部署方式,另有Docker部署方式,請參考文章《Docker 方式部署 Solo 博客系統(tǒng)總結(jié)》
??Solo是專門為程序員提供的開源博客系統(tǒng),他可以在自己的服務(wù)器中部署和維護,有大量精美的皮膚可以選擇,且無廣告,可以根據(jù)自己的需要進行二次開發(fā)。可參考 這個博客 預(yù)覽。下面是自己以 Tomcat 方式部署Solo的一些總結(jié)。
一、環(huán)境和文件準(zhǔn)備
- 服務(wù)器:購買的阿里云服務(wù)器,系統(tǒng)為Linux(Cent OS)。
- JDK:版本1.8 下載
- Tomcat:版本9.0.19 下載
- Solo:war包形式,版本3.6.3 下載
- MySQL 8:通用Linux社區(qū)版 下載
??下載準(zhǔn)備好以上幾個文件后,分別將他們放到Cent OS的相應(yīng)目錄中,具體目錄自己決定。最好新建自己的文件夾,目錄中不要出現(xiàn)中文。
- JDK放在目錄 /usr/local/hudk/JDK/jdk-8u111-linux-x64.tar.gz;
- Tomcat放在目錄 /usr/local/hudk/apache-tomcat-9.0.22-deployer.tar.gz;
- Solo放在/usr/local/hudk/solo-v3.6.3.war。
二、安裝JDK和配置環(huán)境變量
1、解壓
??切換到 /usr/local/hudk/JDK目錄下,解壓JDK壓縮包。執(zhí)行命令:
$ tar -zxvf jdk-8u111-linux-x64.tar.gz2、環(huán)境變量
??新增文件/etc/profile.d/jdk.sh,并編輯它。執(zhí)行命令:
#編輯文件 $ vim /etc/profile.d/jdk.sh??如果/etc/profile.d/下沒有jdk.sh文件,執(zhí)行此命令會自動增加jdk.sh文件,并進入vim編輯器,按鍵盤字母i進入編輯狀態(tài)。編輯如下內(nèi)容:
export JAVA_HOME=/usr/local/hudk/JDK/jdk1.8.0_111 export PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH??分別按鍵盤Esc > (Shift+:) > w >q >Enter 保存并推出編輯模式。執(zhí)行以下命令使jdk.sh文件生效。
$ source /etc/profile.d/jdk.sh??JDK 環(huán)境變量的多種配置形式請參考 《CentOS 安裝 JDK 三種形式詳細總結(jié)》。
三、安裝MySQL
??具體安裝過程參考:《centos7安裝mysql8.0版本教程》。安裝完成后,新建用戶和數(shù)據(jù)庫實例,在后面部署Solo到Tomcat中時,配置文件時會用到。這個假設(shè)用戶名和密碼全是 mj ,數(shù)據(jù)庫實例名為 solo。
四、安裝Tomcat和配置80端口
1、解壓縮
??切換到 /usr/local/hudk/目錄下,解壓apache-tomcat-9.0.22-deployer.tar.gz包。執(zhí)行命令:
$ tar -zxvf apache-tomcat-9.0.22-deployer.tar.gz2、配置 server.xml
??進入tomcat文件目錄/usr/local/hudk/apache-tomcat-9.0.22/conf,找到文件server.xml并編輯它
$ vim ./server.xml??將其中內(nèi)容:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />??修改為:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />五、部署Solo到Tomcat并啟動初始化
1、解壓縮
??首先將 /usr/local/hudk/apache-tomcat-9.0.22/webapps/ROOT/ 目錄清空;再將 /usr/local/hudk/solo-v3.6.3.war 文件解壓到 /usr/local/hudk/apache-tomcat-9.0.22/webapps/ROOT/ 中。
2、修改配置文件
??要想正常訪問Solo,啟動Tomcat前需要配置兩個文件,分別是 latke.properties 、local.properties 。
??先說 latke.properties,這個文件主要配置Solo的訪問域名端口和模式。其中域名和端口,要保持和你將要在瀏覽器中訪問的內(nèi)容一致,比如你的serverHost值是www.mjhdk.cn,那么以后只能使用www.mjhdk.cn域名才可以正常訪問Solo,如果使用IP地址訪問的話,靜態(tài)文件js 和 css等訪問會出現(xiàn)問題,導(dǎo)致頁面無法渲染。
# # Solo - A small and beautiful blogging system written in Java. # Copyright (c) 2010-present, b3log.org # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. ## # Description: B3log Latke configurations. # Version: 1.6.0.2, Mar 19, 2019 # Author: Liang Ding ##### Server #### # Browser visit protocol serverScheme=http serverHost=www.mjhdk.cn serverPort=80#### Runtime Mode #### #runtimeMode=DEVELOPMENT runtimeMode=PRODUCTION??local.properties文件中主要涉及數(shù)據(jù)庫的配置。
# # Solo - A small and beautiful blogging system written in Java. # Copyright (c) 2010-present, b3log.org # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. ## # Description: Solo local environment configurations. # Version: 1.1.3.15, Mar 17, 2019 # Author: Liang Ding ##### MySQL runtime #### runtimeDatabase=MYSQL jdbc.username=*** jdbc.password=****** jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.URL=jdbc:mysql://0.0.0.0:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC#### H2 runtime #### #runtimeDatabase=H2 #jdbc.username=root #jdbc.password= #jdbc.driver=org.h2.Driver #jdbc.URL=jdbc:h2:~/solo_h2/db;MODE=MYSQL# The minConnCnt MUST larger or equal to 3 jdbc.minConnCnt=5 jdbc.maxConnCnt=10# The specific table name prefix jdbc.tablePrefix=b3_solo??最后配置完這兩個文件,就可以嘗試啟動Tomcat了。進入/usr/local/hudk/apache-tomcat-9.0.22/bin目錄,執(zhí)行命令./startup.sh 啟動Tomcat。如果啟動正常,訪問主頁時,會進行自動的數(shù)據(jù)庫初始化過程,即幫你建表和加入初始數(shù)據(jù)。初始化完成后使用自己的GitHub賬戶可以登錄主頁,開啟博客之旅。
總結(jié)
以上是生活随笔為你收集整理的Tomcat 方式部署 Solo 博客系统总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么高效的通过爬虫获取数据?
- 下一篇: 【转】雅典娜与宙斯的对话.(kerber