zoukankan      html  css  js  c++  java
  • linux系统非ROOT用户80端口不能启动tomcat问题的变通办法——通过Iptables端口转发

    2010-07-17 13:21:42 org.apache.tomcat.util.digester.SetPropertiesRule begin 
    警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did not find a matching property. 
    2010-07-17 13:21:42  org.apache.catalina.core.AprLifecycleListener init 
    信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/jdk1.5.0_16/jre/lib/i386/client:/usr/jdk1.5.0_16/jre/lib/i386:/usr/jdk1.5.0_16/jre/../lib/i386 
    2010-07-17 13:21:42  org.apache.coyote.http11.Http11Protocol init 
    严重: Error initializing endpoint 
    java.net.BindException: Permission denied:80 
            at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:502) 
            at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176) 
            at org.apache.catalina.connector.Connector.initialize(Connector.java:1058) 
            at org.apache.catalina.core.StandardService.initialize(StandardService.java:677) 
            at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:795) 
            at org.apache.catalina.startup.Catalina.load(Catalina.java:530) 
            at org.apache.catalina.startup.Catalina.load(Catalina.java:550) 
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
            at java.lang.reflect.Method.invoke(Method.java:585) 
            at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260) 
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412) 
    2010-07-17 13:21:43 org.apache.catalina.startup.Catalina load

    上面可以看到,非root用户其实没有绑定80端口的权限。在Linux下低于1024的端口是root专用,而Tomcat安装后默认使用用户tomcat启动的,所以将端口改为80后启动,会产生错误:java.net.BindException: Permission denied:80

    解决方法是:

    第一步,重将Tomcat的端口(server.xml)由80改回8080。

    第二步,通过Iptables端口实现80到8080的转发,命令为:

    iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

    用root用户直接去执行就可以了!

    这样,用户访问80端口和8080端口其实都到了8080端口。

  • 相关阅读:
    bzoj 3709: [PA2014]Bohater【贪心】
    bzoj 3714: [PA2014]Kuglarz【最小生成树】
    bzoj 2216: [Poi2011]Lightning Conductor【决策单调性dp+分治】
    bzoj 2087: [Poi2010]Sheep【凸包+极角排序+dp】
    bzoj 3830: [Poi2014]Freight【dp】
    bzoj 3930: [CQOI2015]选数【快速幂+容斥】
    bzoj 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式【后缀自动机】
    bzoj 1614: [Usaco2007 Jan]Telephone Lines架设电话线【二分+spfa】
    bzoj 1640||1692: [Usaco2007 Dec]队列变换【后缀数组】
    bzoj 1612: [Usaco2008 Jan]Cow Contest奶牛的比赛【Floyd】
  • 原文地址:https://www.cnblogs.com/tobey/p/4712549.html
Copyright © 2011-2022 走看看