如何让 Tomcat7 在 CentOS 上作为守护进程运行

如何让 Tomcat7 在 CentOS 上作为守护进程运行

Tomcat我正在尝试为on实现 SSL CentOS 6.7。这不是一个蜱虫嵌套问题,也不适用 SELinux,正如其他帖子所解决的那样——至少我不认为它们适用。

server.xml文件有条目:

<Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
               port="443" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="/usr/share/tomcat/.keystore" keystorePass="password-omitted-for-security"  />

密码正确并已使用 keytool 进行验证。

Tomcat 也拥有该文件:

-rwxrwxrwx.   1 tomcat tomcat 7192 Sep  2  2014 .keystore

什么会导致以下情况catalina.out

    SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-nio-443"]
    java.net.SocketException: Permission denied
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:437)
        at sun.nio.ch.Net.bind(Net.java:429)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:475)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:651)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
        at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
        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:821)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:253)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:427)

阿帕奇, Tomcat7 应该作为守护进程运行。然而,他们的指令抛出了自己的异常:

-bash: ./bin/jsvc: No such file or directory

因此,他们提到如果客户端使用不同的虚拟机,我可能需要指定虚拟机,它确实这样做:

echo $JAVA_HOME
/usr/java/jdk1.7.0_79

Tomcat7 使用:

/usr/java/jre1.8.0_51

所以我在 $CATALINA_HOME 中使用:

./bin/jsvc \ -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/tomcat-juli.jar \ 
    -outfile $CATALINA_BASE/logs/catalina.out \ -errfile $CATALINA_BASE/logs/catalina.err \ -Dcatalina.home=$CATALINA_HOME \ 
    -Dcatalina.base=$CATALINA_BASE \ 
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \ 
    -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \ 
    -jvm /usr/java/jre1.8.0_51 \ 
    org.apache.catalina.startup.Bootstrap

结果相同:

-bash: ./bin/jsvc: No such file or directory

请指教

相关内容