JavaWeb Getting Started - Installing Tomcat server in a Linux environment

JavaWeb Getting Started - Installing Tomcat server in a Linux environment

Abstract: This paper learned how to install Tomcat server in a Linux environment.

Ready to work

Check the Java environment variables

Check whether the system is configured Java environment variables:

1 [root@localhost ~]# java -version
2 java version "1.8.0_91"
3 Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
4 Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
5 [root@localhost ~]# 

Java has already been installed, you can proceed, otherwise you need to install Java in order to proceed.

Open the firewall specified port

The default port used by Tomcat is 8080, if the Linux open firewall, but did not release the 8080 port, an IP address can not be accessed by Linux servers.

Check firewall status:

1 [root@localhost bin]# firewall-cmd --state
2 running
3 [root@localhost bin]# 

running means that the firewall is turned on, whether to continue viewing port 8080 has been liberalized:

1 [root@localhost bin]# firewall-cmd --query-port=8080/tcp
2 no
3 [root@localhost bin]# 

no explanation and did not release the 8080 port, you need to manually open:

1 [root@localhost bin]# firewall-cmd --add-port=8080/tcp --permanent
2 success
3 [root@localhost bin]# 

Restart the firewall:

1 [root@localhost bin]# firewall-cmd --reload
2 success
3 [root@localhost bin]# 

8080 Port query again:

1 [root@localhost bin]# firewall-cmd --query-port=8080/tcp
2 yes
3 [root@localhost bin]# 

yes Description Port already open, you can access this server via a 8080 port.

Use the downloaded installation archive

Official website address

Tomcat's official website address:

https://tomcat.apache.org

In the official website address can download the latest version, if you need to download the previous version, by the following address:

https://archive.apache.org/dist/tomcat

Archive version

Each version offers different packages depending on the installation environment, you can download the actual situation:

apache-tomcat-x.zip:Windows foundation release package, APR native libraries under the relevant batch script does not contain Windows services and Windows.

apache-tomcat-x.tar.gz: zip bag with the same, but different compression formats, primarily for Linux system.

apache-tomcat-x.exe: Windows executable installation package, basically the same functions and zip for Windows shortcut keys, and system services in the form of start.

apache-tomcat-x-windows-x86.zip:32 bit Windows release package, comprising APR native libraries for Windows 32-bit system used in conjunction with JVM adapter 32 and the 64-bit operating system.

apache-tomcat-x-windows-x64.zip:64 bit Windows release package, APR native libraries contain 32-bit Windows systems with the use of the JVM, fit only 64-bit operating system.

Note If you need to put on top of Linux, you need to download suffix format  tar.gz  compressed package.

installation

Use a good tool to download files to upload to a PC with Linux systems.

The archive's contents to  / opt  directory:

1 [root@localhost ~]# tar -zxvf /opt/apache-tomcat-9.0.29.tar.gz -C /opt/

Decompression after setup is complete.

Enter the unpacked directory into the  bin  directory, execute  the Startup. SH  files:

1 [root@localhost bin]# ./startup.sh 
2 Using CATALINA_BASE:   /opt/apache-tomcat-9.0.29
3 Using CATALINA_HOME:   /opt/apache-tomcat-9.0.29
4 Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.29/temp
5 Using JRE_HOME:        /opt/jdk1.8.0_91
6 Using CLASSPATH:       /opt/apache-tomcat-9.0.29/bin/bootstrap.jar:/opt/apache-tomcat-9.0.29/bin/tomcat-juli.jar
7 Tomcat started.
8 [root@localhost bin]# 

Open your browser and enter the address of the Linux server is located in the address bar  http://192.168.35.128:8080  , if you see the following pages proved successful start:

If you do not see this page, indicating that 8080 could be a firewall port is not open, then try accessing again the need to manually open.

If you need to shut down Tomcat, need to  bin  execution directory  the shutdown. SH  files:

1 [root@localhost bin]# ./shutdown.sh 
2 Using CATALINA_BASE:   /opt/apache-tomcat-9.0.29
3 Using CATALINA_HOME:   /opt/apache-tomcat-9.0.29
4 Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.29/temp
5 Using JRE_HOME:        /opt/jdk1.8.0_91
6 Using CLASSPATH:       /opt/apache-tomcat-9.0.29/bin/bootstrap.jar:/opt/apache-tomcat-9.0.29/bin/tomcat-juli.jar
7 [root@localhost bin]# 

使用yum命令进行安装

选择版本并安装

使用 yum search tomcat 命令查看可用的安装包:

 1 [root@localhost ~]# yum search tomcat
 2 已加载插件:fastestmirror
 3 Loading mirror speeds from cached hostfile
 4  * base: mirrors.tuna.tsinghua.edu.cn
 5  * extras: mirrors.zju.edu.cn
 6  * updates: mirrors.tuna.tsinghua.edu.cn
 7 ========================================================== N/S matched: tomcat ===========================================================
 8 tomcat-admin-webapps.noarch : The host-manager and manager web applications for Apache Tomcat
 9 tomcat-docs-webapp.noarch : The docs web application for Apache Tomcat
10 tomcat-javadoc.noarch : Javadoc generated documentation for Apache Tomcat
11 tomcat-jsp-2.2-api.noarch : Apache Tomcat JSP API implementation classes
12 tomcat-jsvc.noarch : Apache jsvc wrapper for Apache Tomcat as separate service
13 tomcat-lib.noarch : Libraries needed to run the Tomcat Web container
14 tomcat-servlet-3.0-api.noarch : Apache Tomcat Servlet API implementation classes
15 tomcat-webapps.noarch : The ROOT and examples web applications for Apache Tomcat
16 tomcatjss.noarch : JSS Connector for Apache Tomcat, a JSSE module for Apache Tomcat that uses JSS
17 tomcat.noarch : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API
18 tomcat-el-2.2-api.noarch : Expression Language v2.2 API
19 
20   名称和简介匹配 only,使用“search all”试试。
21 [root@localhost ~]# 

使用 yum install -y tomcat 命令进行安装:

 1 [root@localhost ~]# yum install -y tomcat
 2 已加载插件:fastestmirror
 3 base                                                                                                               | 3.6 kB  00:00:00     
 4 extras                                                                                                             | 2.9 kB  00:00:00     
 5 mysql-connectors-community                                                                                         | 2.5 kB  00:00:00     
 6 mysql-tools-community                                                                                              | 2.5 kB  00:00:00     
 7 mysql56-community                                                                                                  | 2.5 kB  00:00:00     
 8 updates                                                                                                            | 2.9 kB  00:00:00     
 9 Loading mirror speeds from cached hostfile
10  * base: mirrors.tuna.tsinghua.edu.cn
11  * extras: mirrors.zju.edu.cn
12  * updates: mirrors.tuna.tsinghua.edu.cn
13 正在解决依赖关系
14 ...
15 总下载量:61 M
16 Downloading packages:
17 Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
18 ...
19 
20 已安装:
21   tomcat.noarch 0:7.0.76-9.el7_6                                                                                                          
22 ...
23 
24 完毕!
25 [root@localhost ~]# 

不过这种方式不能选择具体的版本,也不能灵活选择安装位置,所以建议使用预先下载好的安装包进行安装。

Guess you like

Origin www.cnblogs.com/shamao/p/11959648.html