所需jdk仓库文件和jpress的war包
迅雷提取
链接:https://pan.xunlei.com/s/VNEG_WXz0KjBPPQhau28-ihpA1#
提取码:4xqs
(jdk-8u144-linux-x64.rpm,不需要配置依赖环境)
1.将jdk-8u144-linux-x64.rpm上传到Linux
上传建议连接xshell
然后点击 需要上传的包,ok。
安装
[root@node3 local]# yum localinstall jdk-8u144-linux-x64.rpm -y
2.去官网选择版本(这里选择的是8.5.20版本)
[root@node3 local]# wget -c https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
#可能会报校验错误,在末尾加个 --no-check-certificate 就行
3.解压到指定目录(一般都解压到 /usr/local /目录底下)
[root@node3 ~]# tar -xf apache-tomcat-8.5.20.tar.gz -C /usr/local
[root@node3 ~]# cd /usr/local/
[root@node3 local]# ll
total 0
drwxr-xr-x 9 root root 160 Oct 12 17:36 apache-tomcat-8.5.20
4.建立软链接
[root@node3 local]# ln -sv /usr/local/apache-tomcat-8.5.20/ /usr/local/tomcat
[root@node3 local]# ll
lrwxrwxrwx 1 root root 32 Oct 12 17:38 tomcat -> /usr/local/apache-tomcat-8.5.20/
建立软链接的好处:
1.减少输入
2.方便升级
[root@node3 bin]# vim /usr/lib/systemd/system/tomcat.service
[Unit]
Description=tomcat service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
ExecStart、ExecStop为安装tomcat时启动,关闭脚本的路径
systemctl enable tomcat
systemctl daemon-reload
问题:
tomcat.service - tomcat
Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2021-03-16 14:23:32 EDT; 3min 33s ago
Process: 1402 ExecStart=/root/apache-tomcat-8.0.53/bin/startup.sh (code=exited, status=1/FAILURE)
Main PID: 1402 (code=exited, status=1/FAILURE)
localhost.localdomain systemd[1]: Starting tomcat...
localhost.localdomain startup.sh[1402]: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
localhost.localdomain startup.sh[1402]: At least one of these environment variable is needed to run this program
localhost.localdomain systemd[1]: tomcat.service: main process exited, code=exited, status=1/FAILURE
localhost.localdomain systemd[1]: Failed to start tomcat.
localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
localhost.localdomain systemd[1]: tomcat.service failed.
关键句:
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
错误为Java环境变量问题
解决方法:
设置环境变量,vim /usr/local/tomcat/bin/catalina.sh,添加:
# JDK
export JAVA_HOME=/usr/local/java/jdk1.8.0_171
export JRE_HOME=/usr/local/java/jdk1.8.0_171/jre
两种方式
第一种方式是直接将程序目录放在webapps目录下面
第二种方式是使用开发工具将程序打包成war包,然后上传到webapps目录下面。
jpress官网:http://jpress.io
下载地址:https://github.com/JpressProjects/jpress
[root@node3 ~]# yum -y install mariadb-server
[root@node3 ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@node3 ~]# mysql
MariaDB [(none)]>
创建jpress数据库
MariaDB [(none)]> create database jpress default character set utf8;
Query OK, 1 row affected (0.00 sec)
设置登陆密码
MariaDB [(none)]> grant all on jpress.* to jpress@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
[root@node3 ~]# mv jpress-web-newest.war /usr/local/tomcat/webapps/
[root@node3 ~]# cd /usr/local/tomcat/webapps/
[root@node3 webapps]# ls
docs examples host-manager jpress-web-newest jpress-web-newest.war manager ROOT
注:war包移动过去会自动解压
浏览器输入http://192.168.10.200:8080/jpress-web-newest/install(以主机ip192.168.10.200为例)
安装完毕!重启tomcat
访问管理员界面
登陆成功!
完成!