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.



-

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.






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

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.