1. 安裝java運行時環(huán)境
本環(huán)境中安裝過java7/java8/java11,最后驗證java-8-oracle是可用的次兆,java-7-oracle以前在ubuntu14.04上驗證可用,java11未驗證過。
ppa方式安裝oracle-java是比較方便的:
apt-get install software-properties-common
add-apt-repository ppa:webupd8team/java
add-apt-repository ppa:linuxuprising/java
apt-get update
https://launchpad.net/~webupd8team/+archive/ubuntu/java
但由于版權(quán)問題,該方式自2019年6月開始不可用栗竖,只能另某出路,后面將列出的三種安裝方式箱亿。
方法一:添加源安裝java-8-oracle
添加opennms源
在/etc/apt/sources.list.d目錄添加opennms.list文件:
deb http://debian.opennms.org/ stable main
安裝倉庫的GPG key
wget -O - http://debian.opennms.org/OPENNMS-GPG-KEY | sudo apt-key add -
更新包索引
apt-get update
安裝oracle-java8-installer和oracle-java8-set-default
apt-get install oracle-java8-installer
apt-get install oracle-java8-set-default
參考:
https://deb.pkgs.org/universal/opennms-stable-amd64/oracle-java8-installer_8u131-1~webupd8~2_all.deb.html
https://deb.pkgs.org/universal/opennms-stable-amd64/oracle-java8-set-default_8u131-1~webupd8~2_all.deb.html
方法二:本地安裝包+oracle java源文件方式j(luò)ava-11-oracle
注冊oracle賬號
https://profile.oracle.com/myprofile/account/create-account.jspx
下載jdk-11.0.3_linux-x64_bin.tar.gz
https://www.oracle.com/technetwork/java/javase/downloads/index.html
新建/var/cache/oracle-jdk11-installer-local/目錄,將jdk文件拷貝到該目錄
mkdir -p /var/cache/oracle-jdk11-installer-local/
cp jdk-11.0.3_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
下載oracle-java11-installer-local和oracle-java11-set-default-local
mkdir java11; cd java11
wget http://ppa.launchpad.net/linuxuprising/java/ubuntu/pool/main/o/oracle-java11-installer-local/oracle-java11-installer-local_11.0.3-1~linuxuprising2_amd64.deb
wget http://ppa.launchpad.net/linuxuprising/java/ubuntu/pool/main/o/oracle-java11-installer-local/oracle-java11-set-default-local_11.0.3-1~linuxuprising2_amd64.deb
安裝oracle-java11-installer-local和oracle-java11-set-default-local
dpkg -i oracle-java11-installer-local_11.0.3-1~linuxuprising2_amd64.deb
apt-get install java-common
dpkg -i oracle-java11-set-default-local_11.0.3-1~linuxuprising2_amd64.deb
參考:
https://www.linuxuprising.com/2019/06/new-oracle-java-11-installer-for-ubuntu.html
方法三:源文件安裝java-7-oracle
下載jdk-7u80-linux-x64.tar.gz
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
解壓jdk-7u80-linux-x64.tar.gz到安裝目錄
mkdir /usr/lib/jvm
tar -zxvf jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm
ln -s /usr/lib/jvm/jdk1.7.0_80 /usr/lib/jvm/java-7-oracle
添加環(huán)境變量聲明腳本
/etc/profile.d/jdk.sh
export J2SDKDIR=/usr/lib/jvm/java-7-oracle
export J2REDIR=/usr/lib/jvm/java-7-oracle/jre
export PATH=$PATH:/usr/lib/jvm/java-7-oracle/bin:/usr/lib/jvm/java-7-oracle/db/bin:/usr/lib/jvm/java-7-oracle/jre/bin
export JAVA_HOME=/usr/lib/jvm/java-7-oracle
export DERBY_HOME=/usr/lib/jvm/java-7-oracle/db
設(shè)置系統(tǒng)默認(rèn)jdk 版本
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-oracle/bin/java 300
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-oracle/bin/javac 300?
update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java-7-oracle/bin/jar 300?
update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java-7-oracle/bin/javah 300?
update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java-7-oracle/bin/javap 300
update-alternatives --config java
參考:
https://www.cnblogs.com/jiangjh/p/10959812.html
2. 安裝tomcat
根據(jù)tomcat支持的jdk版本選擇tomcat,實測發(fā)現(xiàn)agilefant-3.5.4在tomcat8/tomcat9上運行不起來弃秆,估計是容器版本不兼容极景,因此只能選擇tomcat7
Servlet Spec | Apache Tomcat Version | Supported Java Versions
4.0????????????????? | 9.0.x????????????????????????????????? | 8 and later
3.1????????????????? | 8.5.x????????????????????????????????? | 7 and later
3.0????????????????? | 7.0.x????????????????????????????????? | 6 and later(7 and later for WebSocket)
http://tomcat.apache.org/whichversion.html
ubuntu18.04可以直接使用apt-get安裝tomcat8和tomcat9,而tomcat7需要單獨將deb文件下下來安裝:
mkdir tomcat7;cd tomcat7
wget http://security.ubuntu.com/ubuntu/pool/main/t/tomcat7/tomcat7_7.0.52-1ubuntu0.16_all.deb
wget http://security.ubuntu.com/ubuntu/pool/main/t/tomcat7/tomcat7-common_7.0.52-1ubuntu0.16_all.deb
wget http://security.ubuntu.com/ubuntu/pool/main/t/tomcat7/libtomcat7-java_7.0.52-1ubuntu0.16_all.deb
wget http://security.ubuntu.com/ubuntu/pool/main/t/tomcat7/libservlet3.0-java_7.0.52-1ubuntu0.16_all.deb
dpkg -i *
安裝過程中遇到過編譯版本和運行版本不匹配問題,以及tomcat7未找到j(luò)dk問題驾茴,錯誤信息如下:
javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: Unsupported major.minor version 52.0
Unsupported major.minor version 52.0報錯問題解決方案? ->? https://blog.csdn.net/wangmaohong0717/article/details/82869359
tomcat7[821]: * no JDK or JRE found - please set JAVA_HOME
需要查看 /etc/init.d/tomcat7 文件,看其中的 JDK_DIRS 是否正確氢卡,如安裝的是java-8-oracle锈至,則可以將/usr/lib/jvm/java-8-oracle加在后面,使其找到正確的jdk
JDK_DIRS="/usr/lib/jvm/default-java ${OPENJDKS} /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-8-oracle"
3. 安裝mysql
安裝mysql
apt-get install mysql-server-5.7
為避免中文亂碼译秦,需要設(shè)置字符集為utf8(mysql中需要用utf8mb4):
nano /etc/mysql/mysql.conf.d/mysqld.cnf
在Basic Settings后面加兩行
character_set_server=utf8mb4
init_connect='SET NAMES utf8mb4'
nano /etc/mysql/conf.d/mysql.cnf
default-character-set = utf8mb4
創(chuàng)建agilefant數(shù)據(jù)庫
mysql -u root -p
create database agilefant;
grant all on agilefant.* to agilefant@localhost identified by 'agilefant';
exit;
其中root 為mysql用戶名峡捡,agilefant為數(shù)據(jù)庫密碼
4.安裝agilefant
下載地址:https://sourceforge.net/projects/agilefant/files/latest/download
解壓agilefant-3.5.4.zip出其中的agilefant.war
將agilefant.war中/WEB-INF/agilefant.conf密碼替換為前面設(shè)置的
password = "[strong unique password]"
將agilefant.war拷貝到 [Tomcat path]/webapps/ 目錄,其中[Tomcat path]一般為/var/lib/tomcat7
5. 重啟tomcat服務(wù)筑悴,并連接測試
sudo service tomcat7 restart
http://localhost:8080/agilefant
用戶名為admin们拙,密碼是secret
為解決導(dǎo)出圖片中文亂碼問題,如燃盡圖標(biāo)題阁吝,需要安裝中文支持包
apt-get install language-pack-zh-hans
修改/etc/environment(在文件的末尾追加):
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en"
再修改/var/lib/locales/supported.d/local(沒有這個文件就新建砚婆,同樣在末尾追加):
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GBK GBK
zh_CN GB2312
最后,執(zhí)行命令:
locale-gen
對于中文亂碼是空格的情況突勇,安裝中文字體解決装盯。
apt-getinstall fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming
參考:
解決ubuntu的中文亂碼問題? ->? https://yq.aliyun.com/articles/676072
【備注】以上用到文件在阿里云oss上備份了一份,但因其下行流量收費甲馋,需臨時放開權(quán)限埂奈,路徑如下:
https://bowen-box.oss-cn-hangzhou.aliyuncs.com/software/java-7-oracle
https://bowen-box.oss-cn-hangzhou.aliyuncs.com/software/java-8-oracle
https://bowen-box.oss-cn-hangzhou.aliyuncs.com/software/java-11-oracle
https://bowen-box.oss-cn-hangzhou.aliyuncs.com/software/tomcat7
https://bowen-box.oss-cn-hangzhou.aliyuncs.com/software/agilefant
參考文獻:
agilefant安裝指導(dǎo)
https://github.com/Agilefant/agilefant/wiki/Agilefant-installation-guide
agilefant用戶手冊
https://www.agilefant.com/support/user-guide/
虛擬機ubuntu14.04搭建agilefant服務(wù)器
http://www.reibang.com/p/5fcfba292b4f
https://www.cnblogs.com/niuniuc/p/10736499.html
https://www.cnblogs.com/restmad/p/5962463.html