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
相关推荐
渣哥11 分钟前
为什么越来越多公司选择 JAVA?一个老程序员的观察笔记
java
码出极致22 分钟前
电商支付场景下基于 Redis 的 Seata 分布式事务生产实践方案
java·后端
chen_note26 分钟前
Redis数据持久化——RDB快照和Aof日志追加
java·数据库·mybatis·持久化·aof·rdb
superlls1 小时前
(Redis)缓存三大问题及布隆过滤器详解
java·后端·spring
阿里嘎多哈基米1 小时前
二、JVM 入门——(三)栈
java·开发语言·jvm·线程·
lovebugs1 小时前
🚀 Kubernetes核心命令详解:Java开发者必备指南
java·后端·kubernetes
快乐肚皮2 小时前
IntelliJ IDEA Debug 模式功能指南
java·ide·intellij-idea·debug
_風箏2 小时前
SpringBoot【ElasticSearch集成 02】Java HTTP Rest client for ElasticSearch Jest 客户端集成
java·后端·elasticsearch
野犬寒鸦2 小时前
力扣hot100:字母异位词分组和最长连续序列(49,128)
java·数据结构·后端·算法·哈希算法
浮游本尊2 小时前
Java学习第14天 - 微服务架构与Spring Cloud
java