Build Tomcat9 in CentOS7.2 and enable HTTP/2 protocol

Source: Internet
Author: User
Tags openssl rsa openssl version unpack

Build Tomcat9 in CentOS7.2 and enable HTTP/2 protocol

Installation Environment

Operating system: centos7.2

JDK version: jdk-1.8.1

Tomcat version: apache-tomcat-9.0.0.m17.tar.gz

Dependent installation packages:

Apr-1.5.2.tar.gz

Apr-util-1.5.4.tar.gz

Openssl-1.0.2h.tar.gz

The relevant installation package I have uploaded to Csdn and can be downloaded via the link.

Install Apr

First, unzip the installation package for Apr:

TAR-XVF apr-1.5.2.tar.gz

After extracting the number, go to the installation package:

CD apr-1.5.2

Then execute the command:

./configure--PREFIX=/USR/LOCAL/APR

Then execute the command:

Make

Then execute the command:

Make install

Since then, the installation package APR has been successfully installed

Installing Apr-util

First unpack the Apr-util installation package:

TAR-XVF apr-util-1.5.4.tar.gz

Enter the folder directory after unpacking:

CD apr-util-1.5.4

Execute command:

./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR

Then compile:

Make

Then install:

Make install

Since then, the Apr-util installation is complete.

Installing OpenSSL

The version of OpenSSL I'm using here is openssl-1.0.2h.

Unpack the installation package:

TAR-XVF openssl-1.0.2h.tar.gz

Go to the directory of the unpacked installation package:

CD OPENSSL-1.0.2H

Execute the command (note that you must specify shared here):

./config Shared--prefix=/usr/local/openssl

Then compile:

Make

Then install:

Make install

At this point, the OpenSSL installation is complete, the following check whether the installation is successful.

With the command of OpenSSL version, the installation succeeds if the version information is displayed, otherwise the installation fails.

If the following appears, configure the environment variables:

Add the last line in Etc/profile:

Export Openssl=/usr/local/openssl/bin

Export path= $OPENSSL: $PATH: $HOME/bin

Then Source/etc/profile

Run OpenSSL version again to view versions

Installing Tomcat

Suppose that the path to Tomcat is in:/usr/local

Let's unpack the installation package first:

TAR-XVF apache-tomcat-9.0.0.m17.tar.gz

Enter the bin directory of the unpacked installation package:

CD apache-tomcat-9.0.0.m17/bin/

Then unzip a compressed package in this directory:

TAR-XVF tomcat-native.tar.gz

Enter Tomcat-native-1.2.10-src/native:

CD tomcat-native-1.2.10-src/native/

Run the following command:

./configure--prefix=/usr/local/native--WITH-APR=/USR/LOCAL/APR--with-ssl=/usr/local/openssl

Then compile:

Make

Then install:

Make install

Configure LD (append directly to the end of/etc/profile)

Vim/etc/profile

Export Ld_library_path=/usr/local/native/lib: $LD _library_path

Source/etc/profile

Below we generate a certificate. The certificate is generated through OpenSSL.

The directory of the certificate we placed in the Apache Conf directory, namely:

Apache-tomcat-9.0.0.m17/conf, so we first came to the directory:

Cd/usr/local/apache-tomcat-9.0.0.m17/conf

Then generate the certificate (in this step it will require you to fill in some certificate information, just fill it out (below is some of my own information)):

OpenSSL genrsa-out Server.key 2048

OpenSSL rsa-in server.key-out Server.key

OpenSSL req-new-x509-key server.key-out ca.crt-days 3650

Configure Tomcat

Go to the Tomcat conf directory, and then modify the configuration file Server.xml:

Cd/usr/local/apache-tomcat-9.0.0.m17/conf

VI Server.xml

Find the following:

Uncomment this section of the text

and change to the following content:

Save exit.

Start Tomcat

Go to the following directory/usr/local/apache-tomcat-9.0.0.m17/bin, which is the Apache/bin directory to start apache:./startup.sh

Finally, visit https://192.168.7.63:8443

Note: If startup fails, the port number may be occupied (you need to modify the port number, e.g 8443---9443) as follows:

At this point, Tomcat is installed by way of compiling.

Build Tomcat9 in CentOS7.2 and enable HTTP/2 protocol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.