{"id":724,"date":"2018-03-28T10:58:17","date_gmt":"2018-03-28T02:58:17","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=724"},"modified":"2018-03-28T10:58:17","modified_gmt":"2018-03-28T02:58:17","slug":"centos7%e4%b8%ad%e4%bd%bf%e7%94%a8jsvc%e5%90%af%e5%8a%a8tomcatdaemon%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=724","title":{"rendered":"CentOS7\u4e2d\u4f7f\u7528jsvc\u542f\u52a8tomcat(daemon\u6a21\u5f0f)"},"content":{"rendered":"<p>\u5728\u751f\u4ea7\u4e2d\uff0ctomcat\u5e94\u8be5\u4ee5daemon\u7684\u6a21\u5f0f\u8fd0\u884c\uff0c\u800c\u4e14\u5982\u679c\u9700\u8981\u4ee5\u666e\u901a\u7528\u6237\u7684\u8eab\u4efd\u542f\u52a8tomcat\uff0c\u90a3\u4e48\u5c31\u4e0d\u80fd\u4f7f\u75281024\u4ee5\u4e0b\u7684\u7aef\u53e3\uff0c\u8fd9\u662fLiunx\u7cfb\u7edf\u7684\u9650\u5236\uff0c\u53ea\u6709root\u7528\u6237\u624d\u80fd\u4f7f\u7528\u5c0f\u4e8e1024\u7684\u7aef\u53e3\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u5c06tomcat\u914d\u7f6e\u6210\u670d\u52a1\u5462\uff1f\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c31\u6765\u804a\u4e00\u804a<b>jsvc<\/b>\u8fd9\u4e2a\u4e1c\u4e1c\u3002<br \/>\n<b>jsvc<\/b>\u662f\u4ec0\u4e48\uff0c\u7b80\u5355\u7684\u8bb2\uff0c\u5b83\u5c31\u662f\u4e00\u4e2aC\u7a0b\u5e8f\uff0c\u662ftomcat\u53d1\u884c\u7248\u4e2d\u81ea\u5e26\u7684\u4e00\u5957\u4ee3\u7801\uff0c\u8def\u5f84\u5728tomcat\/bin\/commons-daemon-native.tar.gz\u4e2d\u3002\u6709\u4e86<b>jsvc<\/b>\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7b80\u5355\u7684\u5b9a\u5236tomcat\u7684\u542f\u52a8\u811a\u672c\u4f7ftomcat\u6210\u4e3a\u670d\u52a1\uff0c\u6307\u5b9atomcat\u8fd0\u884c\u65f6\u7684\u7528\u6237\u548c\u7ec4\uff0c\u8fd8\u53ef\u4ee5\u5b9a\u5236\u4e00\u4e9bjvm\u7684\u53c2\u6570\u7b49\u7b49\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u4e0b\u9762\u5f00\u59cb\u5b9e\u6218\u914d\u7f6e\uff1a<\/p>\n<h3>1\uff0c\u7cfb\u7edf\u73af\u5883\u8bf4\u660e\uff1a<\/h3>\n<p>\u7cfb\u7edf\u7248\u672c\uff1a<\/p>\n<pre><code>[root@tomcat ~]# cat \/etc\/redhat-release\nCentOS Linux release 7.3.1611 (Core) <\/code><\/pre>\n<p>\u5185\u6838\u7248\u672c\uff1a<\/p>\n<pre><code>[root@tomcat ~]# uname -r\n3.10.0-514.el7.x86_64<\/code><\/pre>\n<p>jdk\u7248\u672c\uff1a<\/p>\n<pre><code>java version \"1.8.0_144\"<\/code><\/pre>\n<p>tomcat\u7248\u672c\uff1a<\/p>\n<pre><code>apache-tomcat-8.5.20<\/code><\/pre>\n<h3>2\uff0cJDK\u5b89\u88c5\uff1a<\/h3>\n<p>\u4e0b\u8f7dJDK\uff0c\u4e3a\u4e86\u548c\u7ebf\u4e0a\u73af\u5883\u4fdd\u6301\u4e00\u81f4\uff0c\u8fd9\u91cc\u4f7f\u7528jdk1.8\u7248\u672c\u7684\u3002\u4e0b\u8f7d\u94fe\u63a5\uff1a<br \/>\n<a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html\" rel=\"nofollow\">http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html<\/a><br \/>\n\u6211\u8fd9\u91cc\u63d0\u524d\u4e0b\u597d\u4e86jdk\uff0c\u6240\u4ee5\u5c31\u76f4\u63a5\u5b89\u88c5\u4e86\u3002<\/p>\n<pre><code>[root@tomcat ~]# cd soft\/\n[root@tomcat soft]# tar xf jdk-8u144-linux-x64.tar.gz -C \/opt\/                                #\u89e3\u538b\u5230opt\u76ee\u5f55\u4e0b\n[root@tomcat soft]# cd \/opt\/\n[root@tomcat opt]# ln -sv jdk1.8.0_144\/ jdk                                                           #\u521b\u5efa\u8f6f\u94fe\u63a5\n\u2018jdk\u2019 -&gt; \u2018jdk1.8.0_144\/\u2019<\/code><\/pre>\n<p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u7f16\u8f91\/etc\/profile.d\/java.sh\uff0c\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code>export JAVA_HOME=\/opt\/jdk\nexport PATH=$JAVA_HOME\/bin:$PATH<\/code><\/pre>\n<p>\u8fd0\u884c\u751f\u6548\uff1a<\/p>\n<pre><code>[root@tomcat ~]# . \/etc\/profile.d\/java.sh<\/code><\/pre>\n<p>\u67e5\u770b\u7248\u672c\u4fe1\u606f\uff1a<\/p>\n<pre><code>[root@tomcat ~]# java -version\njava version \"1.8.0_144\"\nJava(TM) SE Runtime Environment (build 1.8.0_144-b01)\nJava HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)<\/code><\/pre>\n<p>\u51fa\u73b0\u7248\u672c\u4fe1\u606f\u8868\u660e\uff0cjdk\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<h3>3\uff0c\u5b89\u88c5tomcat\uff1a<\/h3>\n<p>tomcat\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/tomcat.apache.org\/download-80.cgi\" rel=\"nofollow\">https:\/\/tomcat.apache.org\/download-80.cgi<\/a>\u00a0\u8fd9\u91cc\u7528<a name=\"baidusnap0\"><\/a><b>tomcat8<\/b>\u7248\u672c\u3002<br \/>\n\u6dfb\u52a0www\u7528\u6237:<\/p>\n<pre><code>[root@tomcat soft]# useradd www<\/code><\/pre>\n<p>\u89e3\u538btomcat\u5230\/opt\/\u4e0b:<\/p>\n<pre><code>[root@tomcat soft]# tar xf apache-tomcat-8.5.20.tar.gz -C \/opt\/\n[root@tomcat opt]# ln -sv apache-tomcat-8.5.20\/ tomcat\n\u2018tomcat\u2019 -&gt; \u2018apache-tomcat-8.5.20\/\u2019                       #\u521b\u5efa\u8f6f\u94fe\u63a5\n[root@tomcat opt]# chown -R www.www tomcat\/       #\u66f4\u6539\u6743\u9650<\/code><\/pre>\n<p>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u7f16\u8f91\/etc\/profile.d\/catalina.sh\uff0c\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code>export CATALINA_HOME=\/opt\/tomcat\nexport CATALINA_BASE=\/opt\/tomcat<\/code><\/pre>\n<p>\u8fd0\u884c\u751f\u6548\uff1a<\/p>\n<pre><code>[root@tomcat ~]# . \/etc\/profile.d\/catalina.sh<\/code><\/pre>\n<h3>4\uff0c\u5b89\u88c5<b>jsvc<\/b>\uff1a<\/h3>\n<p>\u8fdb\u5165tomcat\u4e0b\u9762\u7684bin\u76ee\u5f55\uff1a<\/p>\n<pre><code>[root@tomcat ~]# cd \/opt\/tomcat\/bin\/\n[root@tomcat bin]# tar xf commons-daemon-native.tar.gz\n[root@tomcat bin]# cd commons-daemon-1.0.15-native-src\/unix\/\n[root@tomcat unix]# .\/configure --with-java=$JAVA_HOME\n...\n*** All done ***\nNow you can issue \"make\"\n[root@tomcat unix]# make<\/code><\/pre>\n<p>\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u6587\u4ef6\u5939\u751f\u6210\u4e00\u4e2a<b>jsvc<\/b>\u7684\u6587\u4ef6\uff0c\u5c06\u5b83\u62f7\u8d1d\u5230\/opt\/tomcat\/bin\/\u4e0b\uff1a<\/p>\n<pre><code>[root@tomcat unix]# cp <b>jsvc<\/b> \/opt\/tomcat\/bin\/<\/code><\/pre>\n<p>bin\u76ee\u5f55\u4e0b\u6709\u4e2adaemon.sh\uff0c\u8fd9\u4e2a\u662ftomcat\u670d\u52a1\u7684\u542f\u52a8\u811a\u672c\uff0c\u5c06\u5b83\u590d\u5236\u5230\/etc\/<a name=\"baidusnap3\"><\/a><b>init.d<\/b>\/\u4e0b\uff1a<\/p>\n<pre><code>[root@tomcat bin]# cp daemon.sh \/etc\/<b>init.d<\/b>\/tomcat<\/code><\/pre>\n<p>\u7136\u540e\u6211\u4eec\u9700\u8981\u5bf9\u542f\u52a8\u811a\u672c\u505a\u4e0b\u6539\u52a8\uff1a<\/p>\n<pre><code># chkconfig: 2345 25 85                                              #\u6dfb\u52a0\u5230\u5934\u90e8\uff0c\u8fd9\u662f\u670d\u52a1\u914d\u7f6e\u4fe1\u606f\n# description: Tomcat daemon project\n\nJAVA_HOME=\/opt\/jdk                                                 #\u914d\u7f6e\u73af\u5883\u53d8\u91cf\nCATALINA_HOME=\/opt\/tomcat\n...\ntest \".$TOMCAT_USER\" = . &amp;&amp; TOMCAT_USER=www            #\u5c06tomcat\u7528\u6237\u6539\u4e3awww<\/code><\/pre>\n<p>\u6dfb\u52a0\u670d\u52a1\uff1a<\/p>\n<pre><code>[root@tomcat ~]# chkconfig --add tomcat\n[root@tomcat ~]# chkconfig --list tomcat\n\nNote: This output shows SysV services only and does not include native\n      systemd services. SysV configuration data might be overridden by native\n      systemd configuration.\n\n      If you want to list systemd services use 'systemctl list-unit-files'.\n      To see services enabled on particular target use\n      'systemctl list-dependencies [target]'.\n\ntomcat          0:off   1:off   2:on    3:on    4:on    5:on    6:off<\/code><\/pre>\n<p>\u542f\u52a8\u670d\u52a1\uff1a<\/p>\n<pre><code>[root@tomcat ~]# service tomcat start\n[root@tomcat ~]# netstat -tnlp\nActive Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID\/Program name\ntcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      2626\/<b>jsvc<\/b>.exec\ntcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      862\/sshd\ntcp        0      0 0.0.0.0:8009            0.0.0.0:*               LISTEN      2626\/<b>jsvc<\/b>.exec      <\/code><\/pre>\n<p>\u6253\u5f00\u6d4f\u89c8\u5668\u5c31\u53ef\u4ee5\u8bbf\u95ee\u4e86\u3002\u81f3\u6b64\uff0ctomcat\u5c31\u53ef\u4ee5\u4ee5daemon\u7684\u65b9\u5f0f\u8fd0\u884c\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u751f\u4ea7\u4e2d\uff0ctomcat\u5e94\u8be5\u4ee5daemon\u7684\u6a21\u5f0f\u8fd0\u884c\uff0c\u800c\u4e14\u5982\u679c\u9700\u8981\u4ee5\u666e\u901a\u7528\u6237\u7684\u8eab\u4efd\u542f\u52a8tomcat\uff0c\u90a3\u4e48\u5c31\u4e0d\u80fd\u4f7f\u75281024\u4ee5\u4e0b\u7684\u7aef\u53e3\uff0c\u8fd9\u662fLiunx\u7cfb\u7edf\u7684\u9650\u5236\uff0c\u53ea\u6709root\u7528\u6237\u624d\u80fd\u4f7f\u7528\u5c0f\u4e8e1024\u7684\u7aef\u53e3\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u5c06tomcat\u914d\u7f6e\u6210\u670d\u52a1\u5462\uff1f\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c31\u6765\u804a\u4e00\u804ajsvc\u8fd9\u4e2a\u4e1c\u4e1c\u3002 jsvc\u662f\u4ec0\u4e48\uff0c\u7b80\u5355\u7684\u8bb2\uff0c\u5b83\u5c31\u662f\u4e00\u4e2aC\u7a0b\u5e8f\uff0c\u662ftomcat\u53d1\u884c\u7248\u4e2d\u81ea\u5e26\u7684\u4e00\u5957\u4ee3\u7801\uff0c\u8def\u5f84\u5728tomcat\/bin\/commons-daemon-native.tar.gz\u4e2d\u3002\u6709\u4e86jsvc\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7b80\u5355\u7684\u5b9a\u5236tomcat\u7684\u542f\u52a8\u811a\u672c\u4f7ftomcat\u6210\u4e3a\u670d\u52a1\uff0c\u6307\u5b9atomcat\u8fd0\u884c\u65f6\u7684\u7528\u6237\u548c\u7ec4\uff0c\u8fd8\u53ef\u4ee5\u5b9a\u5236\u4e00\u4e9bjvm\u7684\u53c2\u6570\u7b49\u7b49\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u4e0b\u9762\u5f00\u59cb\u5b9e\u6218\u914d\u7f6e\uff1a 1\uff0c\u7cfb\u7edf\u73af\u5883\u8bf4\u660e\uff1a \u7cfb\u7edf\u7248\u672c\uff1a [root@tomcat ~]# cat \/etc\/redhat-release CentOS Linux release 7.3.1611 (Core) \u5185\u6838\u7248\u672c\uff1a [root@tomcat ~]# uname -r 3.10.0-514.el7.x86_64 jdk\u7248\u672c\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-724","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=724"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/724\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}