Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install tomcat on Centos7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. JDK installation

1 > check the jdk of the current system: rpm-qa | grep jdk

2 > check which JDK: yum search java is in the yum library | grep jdk

3 > Select the package name of the version to be installed and install: yum install java-1.7.0-openjdk-1.7.0.75.x86_64

4 > you can also choose another version or the latest version of JDK that you want to install. Pay attention to modifying the path in the configuration below.

two。 Configure JDK

Set the environment variable root@localhost ~] # vi / etc/profile

Add the following:

# set java environment JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH

Let the changes take effect: [root@localhost java] # source / etc/profile

3. Install tomcat

[root@admin local] cd / usr/local [root@admin local] wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.73/bin/apache-tomcat-7.0.73.tar.gz [root@admin local] tar-zxv-f apache-tomcat-7.0.73.tar.gz / / decompress the package [root@admin local] rm-rf apache-tomcat-7.0.73.tar.gz / / Delete compressed package [root@admin local] mv apache-tomcat-7.0.73 tomcat

Start tomcat:

Cd usr/local/tomcat/bin/. / startup.sh

4. Turn off firewalld, the default firewall for Centos is not iptables, but firewalld. So you need to turn off firewalld.

Systemctl stop firewalld systemctl disable firewalld

5. Install iptables and modify the rules file.

1 > install iptables

# first check whether iptables service iptables status is installed # install iptables yum install-y iptables # upgrade iptables yum update iptables # install iptables-services yum install iptables-services

2 > modify and enable iptables. Add Port 8080 (tomcat) to the iptables file.

Vim / etc/sysconfig/iptables, the first time the new installation is opened, it is empty, paste the following

Iptables-An INPUT-p tcp-- dport 8080-j ACCEPT means opening port 8080.

# Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. * filter: INPUT ACCEPT [0:0]: FORWARD ACCEPT [0:0]: OUTPUT ACCEPT [0:0]-An INPUT-m state-- state ESTABLISHED RELATED-j ACCEPT-An INPUT-p icmp-j ACCEPT-An INPUT-I lo-j ACCEPT-An INPUT-m state-state NEW-m tcp-p tcp-- dport 22-j ACCEPT-An INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT-An INPUT-m state-state NEW-m tcp-p tcp-dport 3306-j ACCEPT-An INPUT-m state-state NEW-mtcp-p tcp- -dport 8080-j ACCEPT-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 8081-j ACCEPT-An INPUT-j REJECT-- reject-with icmp-host-prohibited-A FORWARD-j REJECT-- reject-with icmp-host-prohibited COMMIT

Keep quitting after modification.

3 > enable iptables service

Systemctl enable iptables.service systemctl start iptables.service

6. Verification

Enter http://127.0.0.1:8080/ in the browser to see the tomcat system interface, indicating that the installation is successful!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report