我正在尝试在ubuntu机器(生产环境)上配置tomcat 7(独立),但在启动时遇到以下异常:
Jan 15, 2014 6:24:45 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.0.
Jan 15, 2014 6:24:45 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jan 15, 2014 6:24:46 AM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1 14 Mar 2012)
Jan 15, 2014 6:24:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-80"]
Jan 15, 2014 6:24:46 AM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-apr-80"]
java.lang.Exception: Socket bind failed: [13] Permission denied
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:430)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
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:639)
at org.apache.catalina.startup.Catalina.load(Catalina.java:664)
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:606)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
我使用的是Ubuntu 12.04 LTS,最初我使用“apt-get”安装了oracle JDK 1.7.0_45,然后我下载了tomcat 7.0.50(.gz格式)解压缩并配置它运行(作为非root用户)在端口80上使用authbind(直到这里工作正常)。然后我安装/配置了APR(1.5.0)连接器(我想现在tomcat能够正确加载它):
INFO: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.0.
Jan 15, 2014 6:24:45 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
但是在这次改变之后tomcat无法收听端口80.有什么建议吗?
更新1
想添加这个:当我尝试以root身份运行tomcat时它工作得很好,是否与我创建的运行tomcat(tomcat)的用户有关?配置APR连接器后面对此问题,它与tomcat用户(在端口80上)工作正常。
现在“tomcat”用户具有以下权限:
chown -R /opt/tomcat7 (this is catalina_home)
在配置APR之前,我执行了以下“tomcat”用户命令:
touch /etc/authbind/byport/80
chmod 500 /etc/authbind/byport/80
chown tomcat /etc/authbind/byport/80
更新2
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
如果我从server.xml删除上面提到的APR连接器,tomcat在非root用户的80端口上工作正常,在这种情况下,在启动期间正确初始化“http-bio-80”连接器。虽然APR tomcat在启动时无法初始化“http-apr-80”连接器。