[Linux] Tomcat installation and port configuration [Linux] JDK installation and configuration (linux-tar.gz version)

Installation Environment: Linux (CentOS 64-bit)

Installing the software: apache-tomcat-9.0.20.tar.gz (Download http://tomcat.apache.org/ )

A: JDK installation configuration

  Tomcat is one of the open source and free java Web server, the Apache Software Foundation project, so you want to install java JDk Before you install Tomcat, refer to  [Linux] JDK installation and configuration (linux-tar.gz version)

Two: Tomcat installation configuration

  1, download Tomcat9.0.20, the file apache-tomcat-9.0.20.tar.gz moved to the / usr / tomcat /, and decompression:

  tar -xzvf apache-tomcat-9.0.20.tar.gz

  

  2, view the port and the port occupancy details

  tomcat default port is 8080, as is occupied, you need to modify the port configuration of tomcat

  See all ports: netstat -ntpl 

  View 8080 port is not in use: netstat -tunlp | grep 8080 or lsof -i: 8080  (Note: If no lsof command prompt, use yum install lsof installed)

  

  It said process ID 8080 occupied port 908 of the process,

  View details of the process such as occupation of port 8080, use:

     ps aux | grep 908

  

   It represents running tomcat / apache-tomcat-9.0.20 process takes up 8080 port,

  To kill the process to release the port, use the kill -9 908 closed process 908

  The occupancy is not a tomcat 8080 port, do not need to kill the process, then you need to change the port configuration of tomcat

  2, tomcat port configuration, which modify tomcat conf / server.xml

  There are three ports in server.xml file settings:

  <Server port = "8005" shutdown = "SHUTDOWN">: Use closed

  <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> : 一般应用使用

  <Connector port = "8009" protocol = "AJP / 1.3" redirectPort = "8443" />: is AJP port, i.e. containers, such as APACHE AJP protocol access through port 8009 Tomcat

  vi conf / server.xml

Three: Start Tomcat

  Start tomcat, respectively, into the inside of the bin directory tomcat

  Execution:  ./startup.sh  -> Start tomcat

  Execution: ./shutdown.sh  -> closed tomcat

  Browser, enter: http: // ip: 8080 (ip IP address of the server), you can access tomcat

Four: Set tomcat boot

  1. Find / etc rc.local file in the folder (some folder in /etc/rc.d file), and finally add the following java environment variables and start tomcat command in the file:

  export JAVA_HOME=/usr/java/jdk1.8.0_211

  export JRE_HOME=$JAVA_HOME/jre

  sh /usr/tomcat/apache-tomcat-9.0.20/bin/startup.sh

    

  Save and exit  : wq

  2, rc.local file to add execute permissions

  chmod +x etc/rc.d/rc.local

   3, restart the server, you can access Tomcat

  reboot

Guess you like

Origin www.cnblogs.com/xioawu-blog/p/10989830.html