centos 安装java + tomcat

centos 安装java + tomcat

tomcat支持jsp,apache2支持php

1, 查看是否已经安装java并卸载
shell 复制代码
yum list installed | grep 'java\|jdk\|gcj\|jre'

yum remove -y 
2,安装JAVA-JDK
shell 复制代码
lscpu | grep Architecture # 查看系统架构, x86_64

yum list |grep jdk | grep x86_64

yum install java-1.8.0-openjdk-devel.x86_64

which java # /usr/bin/java
ls -lr /usr/bin/java #  /usr/bin/java -> /etc/alternatives/java
ls -lr  /etc/alternatives/java # /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64/jre/bin/java


echo export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64 >> /etc/profile
echo export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64/jre >> /etc/profile
echo export CLASSPATH=$JAVA_HOME/lib >> /etc/profile
3,配置tomcat

进入tomcat官方地址:https://tomcat.apache.org/ 在左边选择版本,在右边core下面选择下载tar.gz文件。

或者直接:

shell 复制代码
cd /usr/local
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.97/bin/apache-tomcat-8.5.97.tar.gz
tar -xvf apache-tomcat-8.5.97.tar.gz
rm -rf apache-tomcat-8.5.97.tar.gz
ln -s apache-tomcat-8.5.97 tomcat
systemctl stop firewalld # 关闭防火墙

tomcat启动/停止

shell 复制代码
sh /usr/local/tomcat/startup.sh # 启动tomcat
ss -antl # 查看8080端口是否启动 浏览器访问http://ip:8080

sh /usr/local/tomcat/shutdown.sh # 关闭tomcat
4,tomcat配置https

生成证书

shell 复制代码
# 输入密钥比如123456,一路回车就可以
keytool -genkey -v -alias tomcat -keyalg RSA -validity 365 -keystore /usr/local/tomcat/conf/tomcat.keystore

编辑tomcat配置

shell 复制代码
vim /usr/local/tomcat/conf/server.xml
shell 复制代码
# 找到这一段
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO implementation. The default
         SSLImplementation will depend on the presence of the APR/native
         library and the useOpenSSL attribute of the AprLifecycleListener.
         Either JSSE or OpenSSL style configuration may be used regardless of
         the SSLImplementation selected. JSSE style configuration is used below.
    -->
    
 # 加入下面这一段   
 <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
               keystoreFile="conf/tomcat.keystore" keystorePass="123456"/>

重新启动

shell 复制代码
sh /usr/local/tomcat/shutdown.sh # 关闭tomcat
sh /usr/local/tomcat/startup.sh # 启动tomcat
ss -antl # 查看8443是否开启,访问https://ip:8443
相关推荐
学长毕业设计3 小时前
基于SpringBoot的公益基金管理系统(源码+文档+讲解视频)
java·spring boot·后端
东小西3 小时前
【SAA实战】第 3 篇 · 工具调用全攻略:把业务能力交给 Agent 自己调度
java·后端·spring
东小西3 小时前
【SAA实战】第 4 篇 · Agent 短期记忆:saver 让 Agent 跨轮记得住(threadId 隔离)
java·后端·spring
许彰午3 小时前
22-DataCenter报文序列化
java·低代码·架构·状态模式
2601_962065254 小时前
[MySQL] SQL优化之性能分析
java·sql·mysql
小范同学_4 小时前
JDK1.7 与 JDK1.8 HashMap 底层原理对比 + 数组并发扩容死循环详解
java·开发语言
予昊5 小时前
从零实现“在线五子棋对战“:WebSocket 实时通信 + 段位匹配
java·开发语言·网络·websocket
2601_962203515 小时前
【SpringAI入门】初识SpringAI
java
weixin_461408585 小时前
Mybatis-flex小记
java·开发语言·mybatis
2601_962177136 小时前
【MySQL篇】聚合查询,联合查询
android·java·mysql