Local issues can not access the tomcat (non-firewall reasons)

First, the deployment can not access the local tomcat

I am using CentOs6.5.
When deployed jenkins, first installed under Linux tomcat, tomcat after a successful start in Linux can be a normal visit, but less than the local variety of access network (localhost, 127.0.0.1, ip) local and virtual machines can ping pass, or not visit, the following chart You can not access the tomcat
to troubleshoot the problem a bit:

  • Whether or not a port number is occupied
  • Whether tomcat has started normally
  • ip address is entered correctly
  • Whether the virtual machine and the local network can ping
  • Whether the port number is blocked by the firewall

I have tomcat installation directory is / usr / local / tomcat, detailed installation guide can refer to https://www.cnblogs.com/proper128/p/11181760.html, which link to download the tomcat of the above has expired, if you want to download can get the download path Quguan network,
such as: wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz
in accordance with the above configuration after successfully found locally and can not be accessed, which find a lot of blog, many of them describing a firewall issue, but I'm not a firewall problem.

1. Does the port number is occupied

I use the port number is 8081, tomcat default port number is 8080, the use of which does not matter, as long as unoccupied on it.
Use command to see if the port is occupied before the start tomcat. netstat -an | grep 8081
If not occupiedUnoccupied

If you use this port to start over tomcat, then close, go see the port. Find shown below, it is normal. Under normal circumstances, its own practice will not have this problem.After the start, then shut down

2. Verify whether tomcat already on the normal start

Enter the tomcat bin directory, Here Insert Picture Descriptionstart tomcat. ./startup.shThe following is a successful start. Start tomcat
Check whether tomcat start ps -ef | grep tomcat, following successful starttomcat process

3.ping network

虚拟机ping本机,本机ping虚拟机,这个如果有问题的话应该早就发现了。

4.Linux下访问tomcat

使用curl+虚拟机ip地址+端口号
Access tomcat under linux
如果修改tomcat中配置文件servic.xml时没有增加URIEncoding=“UTF-8”,不会出现下面的网址信息。tomcat configuration information
访问失败的提示信息是:Access failure

5.端口号是否被防火墙拦截

最简单的解决方案是关闭防火墙,注意这里的防火墙指的是Linux下的防火墙。
CentOs6.5防火墙命令

  • 关闭:service iptables stop
  • 开启:service iptables start
  • 查看防火墙状态:service iptables status
    关闭之后如果跟还不能访问就不是防火墙的问题了。

还可以添加防火墙的通过端口。
进入防火墙的配置文件 vim /etc/sysconfig/iptables
Firewall Profiles
现在开放了22、8881、8080、80这几个端口,可以把其中某一行复制,把端口号修改了,粘贴到下一行。修改文件后,重新启动防火墙就可以。启动后的显示如下:Firewall state

5.解决方案

最后发现是我虚拟机的问题,虚拟机的网络应该选择桥接模式。
我本地ip是192.168.1.5
虚拟机ip192.168.1.8
service.xml配置文件中主机name是localhost
在Linux中可以使用(localhost、127.0.0.1、192.168.1.8进行访问tomcat)
在本机只能通过192.168.1.8进行访问。

搭配的初衷是为了安装Jenkins,把测试代码进行持续集成。

发布了8 篇原创文章 · 获赞 3 · 访问量 453

Guess you like

Origin blog.csdn.net/qq_45731111/article/details/104454919