How to install and configure JDK and Tomcat on Linux server

Required steps

①ECS install jdk
②ECS install Tomcat

1. ECS install jdk

(1) Download jdk from official website to local

  • Confirm whether your server is Linux 64-bit or 32-bit, select the corresponding jdk
Linux> uname -a

Insert picture description here

(2) Upload the compressed package to the cloud service

I use Xshell to upload, process reference: https://www.cnblogs.com/nbf-156cwl/p/8641165.html

mkdir software	//创建software目录用来保存安装包
rz -y			//上传文件

Insert picture description here
(You can also use a visual panel, such as the pagoda panel to upload, which is very convenient)

  • Unzip jdk
Linux>tar -xvf jdk-14.0.1_linux-x64_bin.tar.gz //输入jdk按tab自动补全

Linux>tar -xvf 压缩包 -C 目录 //这条指令可以将压缩包解压到指定目录下

Insert picture description here

  • Configure the /etc/profile file
用vim编辑器打开:
vim /etc/profile	

Then add environment variables:

进入INSERT模式(可以按"i"键)

将以下的配置加在最后面
export JAVA_HOME=/usr/software/jdk-14.0.1
export JRE_HOME=/usr/software/jdk-14.0.1/jre
export PATH=$PATH:/usr/software/jdk-14.0.1/bin
export CLASSPATH=./:/usr/software/jdk-14.0.1/lib:/usr/software/jdk-14.0.1/jre/lib

然后ESC,输入":wq"(不带“”号),回车写入保存

Insert picture description here

  • Restart configuration: source /etc/profile
  • View version: java -version is
    Insert picture description here
    installed successfully

2. Install Tomcat

  • Go to the official website to download the latest version of the Tomcat installation package http://tomcat.apache.org/
  • Upload to the software directory
Linux> yz -y

Insert picture description here
Insert picture description here

  • Unzip to the specified location
解压到www/server目录下
sudo tar -xvzf apache-tomcat-9.0.36.tar.gz -C /www/server

Insert picture description here

  • Edit profile file
export CATALINA_HOME=/www/server/apache-tomcat-9.0.36
export PATH=$PATH:$CATALINA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:$CATALINA_HOME/lib
export PATH=$PATH:$CATALINA_HOME/bin

Insert picture description here

  • Reload profile
source /etc/profile

Guess you like

Origin blog.csdn.net/weixin_44307065/article/details/107032610
Recommended