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

How to configure tomcat environment variables in CentOS system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is to share with you about how to configure tomcat environment variables in the CentOS system, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

The following sets the tomcat-related environment variables in the CentOS system

] # vi ~ / .bash_profile add tomcat environment parameters

TOMCAT_HOME=/usr/local/tomcat

Export PATH JAVA_HOME CLASSPATH TOMCAT_HOME

Save exit, and then execute source ~ / .bash_profile to make the environment variable take effect

] # source ~ / .bash_profile

Next, you can start the tomcat server on the CentOS system.

[root@localhost opt] # / usr/local/tomcat/bin/startup.sh

Using CATALINA_BASE: / usr/local/tomcat

Using CATALINA_HOME: / usr/local/tomcat

Using CATALINA_TMPDIR: / usr/local/tomcat/temp

Using JRE_HOME: / usr/java/jdk1.7.0

No other information indicates that it has started normally. You can also check whether the tomcat port is open.

# netstat-tnl check the two ports 8080 8009. If it is opened, it proves that the tomcat of the CentOS system is running properly.

Tcp 00: 8009: * LISTEN

Tcp 0 0: 8080: * LISTEN

Let's test it.

If you are not on the CentOS system, you can check the server ip address on the xp system as a local area network access to the Tomcat server # ifconfig that has just been done.

Inet addr:192.168.138.128 Bcast:192.168.138.255 Mask:255.255.255.0

So in the LAN, the xp access address is http://192.168.138.128:8080.

Note that port 8080 should be written.

It is found that the tomcat default page cannot be opened because port 8080 is not allowed because of the default iptables firewall setting in the CentOS system.

# iptables-F this command clears the default rules of iptables's built-in firewall in CentOS5.3

Access If you're seeing this page via a web browser after cleaning.

It means you've setup Tomcat successfully. Congratulations!

Let the server run tomcat automatically when it starts.

Our easiest way is to automatically start Tomcat through startup.sh and edit vi / etc/rc.d/rc.local

The file * adds content (assuming the JDK directory is / usr/java,Tomcat directory is / usr/local/tomcat)

Export JDK_HOME=/usr/java/jdk1.7.0

Export JAVA_HOME=/usr/java/jdk1.7.0

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

Save exit

* restart the server to see if it starts automatically

Shutdown-r now starts slowly. Check that port 8080 opens automatically. It means there's no problem.

Then use the browser to access, found that can not access, it should be the iptables firewall problem

I forgot to save and change the settings of iptables.

# iptables-F

# service iptables save

Saving firewall rules to / etc/sysconfig/iptables: [OK]

Only when these two commands are executed together can they be saved to the CentOS system configuration file, and the next time you boot, you can directly access the jsp web page.

The above is how to configure tomcat environment variables in the CentOS system. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Servers

Wechat

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

12
Report