Centos7.2 install tomcat8

 

tomcat requires java environment, java installation reference: http://youngbrick.iteye.com/blog/2335139

Tomcat official download directory: http://tomcat.apache.org/download-80.cgi

Download address: http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.5.6/bin/apache-tomcat-8.5.6.tar.gz

firewall can refer to: http://www.cnblogs.com/moxiaoan/p/5683743.html

 

I downloaded the compressed package and installed it offline.

Put the compressed package in the /usr/local/ directory

 

Enter the local directory:

 

[root@localhost local]# cd /usr/local/
[root@localhost local]# ls
apache-tomcat-8.5.6.tar.gz  include                     lib64    src
bin                         jdk1.8.0_111                libexec
etc                         jdk-8u111-linux-x64.tar.gz  sbin
games                       lib                         share

 

Unzip tomcat: 

[root@localhost local]# tar -xzvf apache-tomcat-8.5.6.tar.gz
Run tomcat:
[root@localhost local]# ./apache-tomcat-8.5.6/bin/startup.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.5.6
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.5.6
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.6/temp
Using JRE_HOME:        /usr/local/jdk1.8.0_111
Using CLASSPATH:       /usr/local/apache-tomcat-8.5.6/bin/bootstrap.jar:/usr/local/
apache-tomcat-8.5.6/bin/tomcat-juli.jar
Tomcat started.
 

 

You can check whether port 8080 is open through netstat detection:

[root@localhost local]# netstat -tlnp | grep 8080
tcp        0      0 :::8080                     :::*                        LISTEN      
106862/java         
 Access the tomcat page through a browser: http://server ip:8080/

It is not accessible at this time.

 

Detected by Window command:

C:\Users\Administrator>ping server ip

Ping xxxx with 32 bytes of data:
Reply from server ip: bytes=32 time=1ms TTL=60
xxxxx
  Detect tomcat8080 port:
C:\Users\Administrator>telnet server ip 8080
Connecting...Could not open connection to host. on port 8080: connection failed
 It is found that the server 8080 cannot be accessed, it should be that the server port 8080 is not exposed.

 

Expose port 8080 through the firewalld-cmd command:

[root@localhost local]# firewall-cmd --zone=public --add-port=8080/tcp --permanent (--permanent takes effect permanently, it will fail after restart without this parameter)
success

Reload:
[root@localhost local]# firewall-cmd --reload
success
  View all open ports: firewall-cmd --zone=public --list-ports Re-visit http://server ip:8080/ through the browser, and then you can visit the tomcat home page. Here I do not configure the environment variables of tomcat! ! ! ===================================================== ======================= tomcat related environment variables tomcat will load java $JRE_HOME when it starts, if there is no $JRE_HOME configuration, it will use $JAVA_HOME [root@localhost ~ ]# vi /etc/profile
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
export JAVA_HOME=/usr/local/jdk1.8.0_111
export JRE_HOME=/usr/local/jdk1.8.0_111
export PATH=$JAVA_HOME/bin:$PATH

export CATALINA_HOME=/usr/local/apache-tomcat-8.5.6
export CATALINA_BASE=/usr/local/apache-tomcat-8.5.6
export CATALINA_TMPDIR=/usr/local/apache-tomcat-8.5.6/temp
 
After editing, execute the source command to take effect:
[root@localhost ~]# source /etc/profile
[root@localhost ~]# source /etc/profile  

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326975763&siteId=291194637