Centos 7.5安装Java和Tomcat并部署SSL证书

1、yum安装jdk1.8

[root@wzx-linux ~]# yum install java-1.8.0-openjdk* -y

2、查看java版本信息

[root@wzx-linux ~]# java -version

openjdk version "1.8.0_345"
OpenJDK Runtime Environment (build 1.8.0_345-b01)
OpenJDK 64-Bit Server VM (build 25.345-b01, mixed mode)

3、安装tomcat-8.5.78服务

(1)创建tomcat8目录

        [root@wzx-linux ~]# mkdir -p /usr/local/tomcat8

(2)创建ssl目录,用于放置SSL证书

        [root@wzx-linux ~]# mkdir -p /usr/local/tomcat8/ssl/

(3)解压tomcat包

        [root@wzx-linux ~]# tar -xf apache-tomcat-8.5.78.tar.gz

(4)将解压后的文件,移动到/usr/local/tomcat8/目录下

        [root@wzx-linux ~]# mv apache-tomcat-8.5.78/* /usr/local/tomcat8/

(5)进入到tomcat服务的bin目录下

        [root@wzx-linux ~]# cd /usr/local/tomcat8/bin/

(6)启动tomcat服务

        [root@wzx-linux bin]# ./startup.sh

Using CATALINA_BASE:   /usr/local/tomcat8
Using CATALINA_HOME:   /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.

(7)查看java程序端口监听

[root@wzx-linux bin]# netstat -anptu | grep java

tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      2782/java           
tcp6       0      0 :::8080                 :::*                    LISTEN      2782/java   

4、访问验证

Centos 7.5安装Java和Tomcat并部署SSL证书_第1张图片

5、tomcat服务配置SSL证书

(证书文件可在百度智能云、阿里、腾讯等云厂商申请免费证书)

(1)编辑server.xml配置文件

[root@wzx-linux ~]# vim /usr/local/tomcat8/conf/server.xml


        
            
        
    

Centos 7.5安装Java和Tomcat并部署SSL证书_第2张图片

(2)重启tomcat服务,先停止,后再启动

(需要注意,停止和启动服务时,是否有报错,如有证明配置有问题,需要详细检查配置)

[root@wzx-linux bin]# ./shutdown.sh

Using CATALINA_BASE:   /usr/local/tomcat8
Using CATALINA_HOME:   /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Using CATALINA_OPTS:   

[root@wzx-linux bin]# ./startup.sh

Using CATALINA_BASE:   /usr/local/tomcat8
Using CATALINA_HOME:   /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.

(3)查看服务端口是否正常监听

[root@wzx-linux bin]# netstat -anptu | grep 443

tcp6       0      0 :::443                  :::*                    LISTEN      14274/java          
tcp6       0      0 172.17.2.9:443          172.17.2.7:63200        TIME_WAIT   -                   

[root@wzx-linux bin]# netstat -anptu | grep java

tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      14274/java          
tcp6       0      0 :::8080                 :::*                    LISTEN   

6、访问测试

Centos 7.5安装Java和Tomcat并部署SSL证书_第3张图片

附:

tomcat包下载地址:Apache Tomcat® - Apache Tomcat 8 Software Downloads

tomcat-8.5.78包:

链接: 百度网盘 请输入提取码

提取码: vegj

你可能感兴趣的:(linux,web,tomcat,java,centos)