1. 安装java运行时环境
本环境中安装过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
但由于版权问题,该方式自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源文件方式java-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
添加环境变量声明脚本
/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
设置系统默认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
参考:
Ubuntu18.04 安装 JDK7
https://www.cnblogs.com/jiangjh/p/10959812.html
2. 安装tomcat
根据tomcat支持的jdk版本选择tomcat,实测发现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未找到jdk问题,错误信息如下:
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
为避免中文乱码,需要设置字符集为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
创建agilefant数据库
mysql -u root -p
create database agilefant;
grant all on agilefant.* to agilefant@localhost identified by 'agilefant';
exit;
其中root 为mysql用户名,agilefant为数据库密码
4.安装agilefant
下载地址:https://sourceforge.net/projects/agilefant/files/latest/download
解压agilefant-3.5.4.zip出其中的agilefant.war
将agilefant.war中/WEB-INF/agilefant.conf密码替换为前面设置的
password = "[strong unique password]"
将agilefant.war拷贝到 [Tomcat path]/webapps/ 目录,其中[Tomcat path]一般为/var/lib/tomcat7
5. 重启tomcat服务,并连接测试
sudo service tomcat7 restart
http://localhost:8080/agilefant
用户名为admin,密码是secret
为解决导出图片中文乱码问题,如燃尽图标题,需要安装中文支持包
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
最后,执行命令:
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上备份了一份,但因其下行流量收费,需临时放开权限,路径如下:
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安装指导
https://github.com/Agilefant/agilefant/wiki/Agilefant-installation-guide
agilefant用户手册
https://www.agilefant.com/support/user-guide/
虚拟机ubuntu14.04搭建agilefant服务器
https://www.jianshu.com/p/5fcfba292b4f
Ubuntu 18.04安装Java JDK8三种方式
https://www.cnblogs.com/niuniuc/p/10736499.html
Ubuntu 安装 JDK 7 / JDK8 的两种方式
https://www.cnblogs.com/restmad/p/5962463.html