Install JDK and Tomcat on Linux

1. Download the installation package

  1. Download JDK_8 , because when downloading JDK, you need to register to download, choose the corresponding system versionxxxx.tar.gz
    insert image description here
  2. Download Tomcat_8 , select Coretar.gz
    insert image description here

2. Install JDK

  1. Upload the JDK to /usr/local/jdk/the directory .
    insert image description here
  2. Unzip the installation package
 # 解压 jdk 安装包
 [root@localhost jdk] tar -zxvf jdk-8u351-linux-x64.tar.gz

insert image description here

  1. Configure environment variables
 # 打开配置环境变量的文件
 [root@localhost jdk]# vim /etc/profile

 # 点击 i,插入以下四行内容
 JAVA_HOME=/usr/local/jdk/jdk1.8.0_351
 CLASSPATH=.:$JAVA_HOME/lib.tools.jar
 PATH=$JAVA_HOME/bin:$PATH
 export JAVA_HOME CLASSPATH PATH
 # 输入以上内容后,点击 esc,然后点击英文冒号,在输入wq

insert image description here

 # 刷新配置
 [root@localhost jdk] source /etc/profile
 # 查看Java版本
 [root@localhost jdk] java -version

insert image description here

3. Install Tomcat

  1. Upload Tomcat to /usr/local/the directory .
    insert image description here
  2. Unzip the installation package
 # 解压 tomcat 安装包
 [root@localhost local] tar -zxvf apache-tomcat-8.5.83.tar.gz

insert image description here

  1. enable tomcat
 # 进入到 tomcat 的 bin 下
 [root@localhost ~] cd /usr/local/apache-tomcat-8.5.83/bin
 # 启用 tomcat
 [root@localhost bin] ./start.sh

insert image description here

4. Access via browser

At this time, visit the tomcat of linux through the local browser. If the tomcat page can be displayed, the configuration is successful. Enter the IP address of linux in the browser, and the port is 8080, which is the default URL of tomcat.
insert image description here

5. Other configurations of tomcat

  1. close tomcat
 # 在 /usr/local/apache-tomcat-8.5.83/bin 目录下
 [root@localhost bin] ./shutdown.sh

insert image description here

  1. Configure the port of tomcat
 # 在 /usr/local/apache-tomcat-8.5.83/conf 下,修改 server.xml 文件
 [root@localhost conf] vim server.xml

http 访问端口:
insert image description here
Shutdown 端口:
insert image description here
JVM启动端口:
insert image description here

  1. Configure the application in tomcat.
 # 将 .war 的包放到此目录中,war 会自动解压
 [root@localhost conf] cd /usr/local/apache-tomcat-8.5.83/webapps
 
 webapps                       -- web应用所在目录
 |--- html, jsp, css, js文件等  -- 这些文件一般在web应用根目录下,根目录下的文件外界可以直接访问.
 |--- WEB-INF 目录              -- java类、jar包、web配置文件存在这个目录下,外界无法直接访问,由web服务器负责调用.
       |--- classes 目录        -- java类
       |--- lib 目录            -- java类运行所需要的jar包
       |--- web.xml 文件        -- web应用的配置文件

Guess you like

Origin blog.csdn.net/Hg_Re_B/article/details/127610280