A tutorial on IPV4 addresses to Apache Tomcat in CentOS

Source: Internet
Author: User
Tags bind centos tomcat tomcat server apache tomcat

Today we're going to learn how to bind IPv4 to Tomcat in a CentOS 7 Linux distributed System.

Apache Tomcat is an open source Web server and Servlet container developed by the Apache Software Foundation. It implements the Java Servlet,javaserver page (JSP), the Java Unified Expression language, and the Sun Microsystems Java WebSocket Specification, and provides a Web server environment to run Java code.

If our web server does not function because Tomcat defaults to IPV6, it is necessary to bind Tomcat to IPV4. As we all know, IPv6 is a modern method of assigning IP addresses to devices, although it may be applied in the near future, but it is not fully applied now. Because of its usefulness, we do not need to convert our Tomcat server to IPv6 at this time, and we should bind it to IPv4.

Before we start to bind Tomcat to IPv4, we should make sure that Tomcat is already installed in our CentOS 7.

1. Switch to Tomcat user

First, we're going to switch to Tomcat users. We can do this by running the SU Tomcat command in the shell or terminal.

The code is as follows:

# su Tomcat

2. Find the file catalina.sh

Now we're going to go into the Bin folder in the Apache Tomcat installation directory, usually/usr/share/apache-tomcat-8.0.x/bin/, where x is the version number of the Apache Tomcat release. Because the version I installed on my CentOS 7 server is 8.0.18, my directory here is/usr/share/apache-tomcat-8.0.18/bin/.

The code is as follows:

$ cd/usr/share/apache-tomcat-8.0.18/bin

Note: Please replace 8.0.18 with the version number of Apache Tomcat installed in your system.

In the bin directory, there is a script file with the name catalina.sh. This is the file we want to edit, and we'll add a row of Tomcat bindings to IPV4 configuration information. You can view this file by running command LS in the shell or terminal.

The code is as follows:

$ ls

3. Configure catalina.sh

As shown in the figure, we will add a line java_opts= "$JAVA _opts-djava.net.preferipv4stack=true-djava.net.preferipv4addresses" at the end of the catalina.sh script file. We can use our favorite text editor to edit this file, such as Nano, Vim, and so on. Here we use the Nano.

Copy Code

The code is as follows:

$ nano catalina.sh

The row is then added to the file as shown in the following illustration.

Now, we have added the configuration information to the file. Save the file and exit the Nano.

4. Reboot

Now we have the configuration in effect by restarting the Tomcat server. We need to run shutdown.sh first, then run startup.sh.

The code is as follows:

$./shutdown.sh

Run executable file startup.sh:

The code is as follows:

$./startup.sh

This will reboot our Tomcat server and load configuration information that binds the server to IPV4.

End

Well, we finally bound the Tomcat server that we ran on the CentOS 7 Linux distribution to the IPV4. Although IPV6 may be applied in the near future, it is also easy to bind Tomcat to IPV4 because it is not yet used, and if your Tomcat server does not work because it binds your Tomcat server to IPV6. If you have any questions, suggestions, feedback, please write it down in the comments box below and let us know what needs to be added or improved. Thank you so much!

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.