Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tomcat single instance deployment

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Tomcat singleton deployment

Introduction

Decompress with the existing tomcat and jdk package + put it to the specified installation location + ln-s to create a soft link and rename it.

Install mariadb-server mariadb softwar

Tomcat:

It is called Java container, web container, web middleware.

The service environment used to run Java web applications. The source file for a Java web application is usually * .jsp. The service environment of JSP consists of jdk and tomcat software.

Software deployment

Extract the downloaded jdk and tomcat packages to the directory specified by the system, configure the environment variable file, and start the tomcat service. The focus of the later stage: using tomcat to publish jsp website applications. The method of publishing a website is somewhat similar to Apache and nginx.

Access process

Client browser-"web server (apache, nginx, tomcat) -" website file

Port number

eighty

Tomcat official website: http://tomcat.apache.org/

Jdk official website: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Option 1: singleton deployment

①: deploy a Java environment

Deploy the JAVA environment tar xf jdk-8u91-linux-x64.tar.gz-C / usr/local to extract the jdk to the / usr/local directory

Method 1 (preferred):

Ln-s / usr/local/jdk1.8.0_91 / usr/local/java

Mode 2 (alternative):

Mv / usr/local/jdk1.8.0_91 / usr/local/java

Modify the environment variable:

Method 1 (preferred): create your own startup script

Vim / etc/profile.d/jdk.sh

JAVA_HOME=/usr/local/java

PATH=$JAVA_HOME/bin:$PATH

Export JAVA_HOME PATH

Mode 2 (alternative): write to the startup script that comes with the system

Vim / etc/profile

JAVA_HOME=/usr/local/java

PATH=$JAVA_HOME/bin:$PATH

Export JAVA_HOME PATH

To make the script effective:

Source / etc/profile.d/jdk.sh or source / etc/profile

Echo $PATH

Test the Java environment:

Env | grep JAVA is selected, and the results are as follows

JAVA_HOME=/usr/local/java

Java-version is required. As long as you see the following information, it means that jdk has been configured.

Java version "1.8.0,91"

Java (TM) SE Runtime Environment (build 1.8.0_91-b14)

Java HotSpot (TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

-

You can delete openjdk directly.

# yum erase $(rpm-qa | grep jdk)-y

②: install tomcat (decompress and rename)

Tar xf apache-tomcat-7.0.34.tar.gz-C / usr/local/ln-s / usr/local/apache-tomcat-7.0.34 / usr/local/tomcat

Then, define the environment variables required by Tomcat:

Vim / etc/profile.d/tomcat.sh / / defines the Tomcat environment variable

CATALINA_HOME=/usr/local/tomcat / / Tomcat installation directory (benchmark, work)

Export CATALINA_HOME

Load the environment variable file source / etc/profile.d/tomcat.sh

Start Tomcat

/ usr/local/tomcat/bin/startup.sh / / start tomcat

Using CATALINA_BASE: / usr/local/tomcat

Using CATALINA_HOME: / usr/local/tomcat

Using CATALINA_TMPDIR: / usr/local/tomcat/temp

Using JRE_HOME: / usr/java/jdk1.7.0_11

Using CLASSPATH: / usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Netstat-tnlp | grep java

Tcp 00:: ffff:127.0.0.1:8005: LISTEN 6191/java

Tcp 00: 8009: LISTEN 6191/java

Tcp 0 0: 8080: * LISTEN 6191/java

/ usr/local/tomcat/bin/shutdown.sh / / close tomcat

About tomcat Port: 8080 8005 8009

The Tomcat server establishes a connection with the client program through the Connector connector component, and the Connector component is responsible for receiving the client's request and sending the response result of the Tomcat server to the client. By default, Tomcat configures two connectors in server.xml:

The first connector listens on port 8080 and is responsible for establishing a HTTP connection. This connector is used when accessing the Web application of the Tomcat server through a browser.

The second connector listens on port 8009 and is responsible for establishing connections to other HTTP (apache) servers. This connector is needed when integrating Tomcat with other HTTP servers.

8005 is the port of tomcat itself

③: testing

Http://192.168.11.11:8080/

Directory structure

[root@tomcat webapps] # tree-L 1 / usr/local/tomcat/ description:-L is the abbreviation of level level

/ usr/local/tomcat/ # working directory of tomcat

├── bin # starts the shutdown command

├── conf # profile

├── lib

├── LICENSE

├── logs # log catalina.out

├── NOTICE

├── RELEASE-NOTES

├── RUNNING.txt

├── temp

├── webapps # save site (project-- directory) directory default website is ROOT

└── work

After the above steps are completed at one time

In-class exercise: generate a static web page for a.html in the / usr/local/tomcat/webapps/ROOT directory.

Echo'> / usr/local/tomcat/webapps/ROOT/b.html

Echo "current date: $(date)" > > / usr/local/tomcat/webapps/ROOT/b.html

Win7/10 browser access test: 192.168.11.11:8080/a.html

II. Install MySQL (brief)

# yum install mariadb mariadb-server-y

# systemctl start mariadb & & systemctl enable mariadb

Three: deploy jspgou

Ls / usr/local/tomcat/webapps/ the base directory of the default website base

Docs examples host-manager manager ROOT

Ls / usr/local/tomcat/webapps/ROOT / / the home directory of the default website

1. Create a database

Mysql-e'create database jspgou CHARACTER SET = utf8;show databases;'

two。 Change the database link:

Wget http://bbs.jeecms.com/fabu/62873.jhtml

Unzip jspgouV6-ROOT.zip

Ls ROOT DB

\ cp-Rv ROOT / usr/local/tomcat/webapps/

Line 20 of the ROOT/WEB-INF/config/jdbc.properties file in the package

Vim / usr/local/tomcat/webapps/ROOT/WEB-INF/config/jdbc.properties modifies the following

The database name created by jdbc.url=jdbc:mysql://127.0.0.1:3306/? characterEncoding=UTF-8

Jdbc.username=root # must use a regular account in a production environment

Jdbc.password=123

3. Import data:

Import the jspgou.sql file from the DB file in the compressed package into the created jspgou database. If the sql statement is too long during the import, please modify the max_allowed_packet parameter in the mysql configuration file my.cnf to 64m, and the default is 1m.

If you report an error when importing the database: change all field defaults of datetime type to CURRENT_TIMESTAMP

Note: if you use the Mariadb database without the above error, you can import it directly.

Change to the DB directory

Cd / DB

[root@tomcat DB] # mysql-uroot-P123-D jspgou < jspgou.sql

4. Deploy the website:

Copy the extracted ROOT folder to the webapps folder under the tomcat installation directory (for example: d:\ Tomcat7\ webapps\), and start tomcat

Cd to the root directory

Do the cp operation again

\ cp-Rv ROOT / usr/local/tomcat/webapps/

Enter the following address. If it can be displayed normally, the deployment is successful.

System management backend login: http://192.168.11.11:8080/jeeadmin/jspgou/index.do

User name: admin

Secret code: 123456

After logging in:

Picture

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report