Get the App
SLTechnology News&Howtos  ›  Database  › 

Tomcat+jsp accesses mysql

Shulou Source: shulou.com Published: 2022-06-01 04:55:18 11月14日 Update

1. JDK environment variable setting (/ etc/profile)

Export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

Export JRE_HOME=$ {JAVA_HOME} / jre

Export JAVA_BIN=$ {JAVA_HOME} / bin

Export CLASSPATH=.:$ {JAVA_HOME} / lib:$ {JRE_HOME} / lib

Export PATH=$ {JAVA_HOME} / bin:$PATH

2. The Tomcat installation package is placed in the / usr/local/tomcat directory without installation.

Tomcat startup: / usr/local/tomcat/bin/catalina.sh start

Tomcat shutdown: / usr/local/tomcat/bin/catalina.sh stop

Or configure the service file / etc/init.d/tomcat:

Systemctl enable tomcat

Systemctl restart tomate

#! / bin/bash

# BEGIN INIT INFO

# Provides: tomcat

# Required-Start: $local_fs $remote_fs $network $syslog

# Required-Stop: $local_fs $remote_fs $network $syslog

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: starts the tomcat

# Description: Tomcat server daemon

# END INIT INFO

JAVA_OPTS='-server-Xms64m-Xmx128m'

JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/

CATALINA_HOME=/usr/local/tomcat

# export JAVA_OPTS JAVA_HOME CATALINA_HOME

$CATALINA_HOME/bin/catalina.sh $*

~

Modify the tomcat configuration:

A. / usr/local/tomcat/conf/tomcat-users.xml

Add the following configuration

For Manager APP u

B. / usr/local/tomcat/conf/server.xml modify server configuration

Port modified to 80

ConnectionTimeout= "20000"

RedirectPort= "8443" / >

Add virtual host

UnpackWARs= "true" autoDeploy= "true" >

Prefix= "localhost_access_log." Suffix= ".txt"

Pattern= "h l u t" r "s b" / >

Modify / etc/hosts file

192.168.99.101 www.test1.com

3. Officially download mysql-connector-java-5.1.48.tar.gz

Copy the file. / mysql-connector-java-5.1.48/mysql-connector-java-5.1.48-bin.jar to the / usr/local/tomcat/lib directory

4. Static file writing test.jsp

6. Excute

7.Others

HTTPS Enable

1. Generate keystore Wuxi Gynecological examination Hospital http://www.87554006.com/

Keytool-genkey-v-alias testKey-keyalg RSA-validity 3650-keystore test.keystore

two。 Copy to path / test.keystore

Root@ubuntu:/usr/local/tomcat# find. -name test.keystore

. / conf/test.keystore

3. Set up server.xml

/ usr/local/tomcat/conf/server.xml

MaxThreads= "150" SSLEnabled= "true" scheme= "https" secure= "true"

ClientAuth= "false" sslProtocol= "TLS" keystoreFile= "/ test.keystore" keystorePass= "111111" / >

View keystore information

Root@ubuntu:/# keytool-list-v-keystore test.keystore

Enter keystore password:

Keystore type: jks

Keystore provider: SUN

Your keystore contains 1 entry

Alias name: testkey

Creation date: Jul 31, 2019

Entry type: PrivateKeyEntry

Certificate chain length: 1

Certificate [1]:

Owner: CN=x, OU=t, O=tx, L=sh, ST=sh, C=cn

Issuer: CN=x, OU=t, O=tx, L=sh, ST=sh, C=cn

Serial number: 4ff9404b

Valid from: Wed Jul 31 16:58:42 CST 2019 until: Sat Jul 28 16:58:42 CST 2029

Certificate fingerprints:

MD5: E1:5D:D1:D4:09:5C:A6:05:2A:E2:7A:2F:83:24:F4:B5

SHA1: C9:4D:FA:96:96:EC:CC:74:5B:A3:6E:7B:01:E3:E5:A6:69:87:FC:12

SHA256: BD:EB:3C:C9:37:B3:A0:9C:FC:2B:D9:D4:5D:8C:6C:08:46:BB:06:1B:65:26:56:90:D3:01:1F:33:C9:75:D2:D4

Signature algorithm name: SHA256withRSA

Subject Public Key Algorithm: 2048-bit RSA key

Version: 3

Extensions:

# 1: ObjectId: 2.5.29.14 Criticality=false

SubjectKeyIdentifier [

KeyIdentifier [

0000: 98 8C 07 FF 38 6D 70 450 D CE 07 04 50 39 2D 8B .8mpE. P9 -.

0010: 06 44 0B 36 .D.6

]

]

* * *

* * *

Warning:

The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool-importkeystore-srckeystore test.keystore-destkeystore test.keystore-deststoretype pkcs12".

Root@ubuntu:/#

Tags: File configuration copy directory no host information hospital variable gynaecology gynecological examination official environment port virtual host path static Wuxi a. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology vpn OPPO Reno NVidia Huawei