tomcat7改为80端口报错解决

tomcat7端口改为80后无法正常监听80端口,查看日志文件/var/log/tomcat7/catalina.XX.log报错信息如下:


SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]                                                    
java.net.BindException: Permission denied :80                                                                                       
        at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)                                                              
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)                                                    
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:423)                                                             
        at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)                                  
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:974)                                                       
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)                                                            
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)                                                
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)                                                            
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)                                                  
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)                                                            
        at org.apache.catalina.startup.Catalina.load(Catalina.java:624)                                                                   
        at org.apache.catalina.startup.Catalina.load(Catalina.java:649)                                                                   
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                    
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)                                                  
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                          
        at java.lang.reflect.Method.invoke(Method.java:622)                                                                               
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)                                                                 
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)                                                                 
Caused by: java.net.BindException: Permission denied                                                                                      
        at java.net.PlainSocketImpl.socketBind(Native Method)                                                                             
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353)                                                        
        at java.net.ServerSocket.bind(ServerSocket.java:336)                                                                              
        at java.net.ServerSocket.(ServerSocket.java:202)                                                                            
        at java.net.ServerSocket.(ServerSocket.java:158)                                                                            
        at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:49)                         
        at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:393)                                                              
        ... 17 more                                                                                                                       
Dec 16, 2016 5:07:10 PM org.apache.catalina.core.StandardService initInternal                                                             
SEVERE: Failed to initialize connector [Connector[HTTP/1.1-80]]                                                                           
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]                                           
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)                                                            
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)                                                
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)                                                            
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)                                                  
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)                                                            
        at org.apache.catalina.startup.Catalina.load(Catalina.java:624)                                                                   
        at org.apache.catalina.startup.Catalina.load(Catalina.java:649)                                                                   
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                    
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)                                                  
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                          
        at java.lang.reflect.Method.invoke(Method.java:622)                                                                               
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)                                                                 
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)                                                                 
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed                                                 
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:976)                                                       
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)                                                            
        ... 12 more                                                                                                                       
Caused by: java.net.BindException: Permission denied :80                                                                            
        at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)                                                                                                                                         

解决:
1. /etc/tomcat7/server.xml中将端口8080改为80:

 
Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />

2. tomcat7使用<1024的端口需要root权限,因此需要修改文件/etc/default/tomcat7中如下内容:
 
TOMCAT7_USER=root
TOMCAT_GROUP=root
AUTHBIND=yes

3. 重启tomcat7服务
 
/etc/init.d/tomcat7 restart
netstat -anupt | grep 80

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值