安装jsvc

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装jsvc相关的知识,希望对你有一定的参考价值。

参考技术A 安装jsvc(利用tomcat方式):

进入tomcat下面的bin目录:

[root@tomcat ~]# cd /opt/tomcat/bin/

[root@tomcat bin]# tar xf commons-daemon-native.tar.gz

[root@tomcat bin]# cd commons-daemon-1.0.15-native-src/unix/

[root@tomcat unix]# ./configure --with-java=$JAVA_HOME

...

*** All done ***

Now you can issue "make"                      

[root@tomcat unix]# make

编译完成后,会在当前文件夹生成一个jsvc的文件,将它拷贝到/opt/tomcat/bin/下:

tomcat目录可自行设置

[root@tomcat unix]# cp jsvc /opt/tomcat/bin/

安装jsvc(无tomcat方式,利用commons-daemon-native.tar.gz和commons-daemon-1.1.0.jar)

将commons-daemon-native.tar.gz放到某个目录,这里放到/opt/jsvc

[root@localhost jsvc]# cd /opt/jsvc

[root@localhost jsvc]# ll

total 404

-rw-r--r--. 1 root root  25145 Aug 15 23:03 commons-daemon-1.1.0.jar

drwxr-xr-x. 4 root root    109 Aug 15 23:03 commons-daemon-1.1.0-native-src

-rw-r--r--. 1 root root 207125 Aug 15 23:03 commons-daemon-1.1.0-native-src.tar.gz

-rwxr-xr-x. 1 root root 174312 Aug 15 23:05 jsvc

解压commons-daemon-1.1.0-native-src.tar.gz

[root@localhost jsvc]# tar -xvf commons-daemon-1.1.0-native-src.tar.gz

commons-daemon-1.1.0-native-src/LICENSE.txt

commons-daemon-1.1.0-native-src/RELEASE-NOTES.txt

commons-daemon-1.1.0-native-src/NOTICE.txt

commons-daemon-1.1.0-native-src/README

commons-daemon-1.1.0-native-src/unix/

commons-daemon-1.1.0-native-src/unix/man/

commons-daemon-1.1.0-native-src/unix/native/

commons-daemon-1.1.0-native-src/unix/support/

commons-daemon-1.1.0-native-src/unix/configure.in

commons-daemon-1.1.0-native-src/unix/INSTALL.txt

commons-daemon-1.1.0-native-src/unix/man/jsvc.1.xml

commons-daemon-1.1.0-native-src/unix/man/README

commons-daemon-1.1.0-native-src/unix/native/debug.c

commons-daemon-1.1.0-native-src/unix/native/.indent.pro

commons-daemon-1.1.0-native-src/unix/native/locks.h

commons-daemon-1.1.0-native-src/unix/native/help.c

commons-daemon-1.1.0-native-src/unix/native/replace.c

commons-daemon-1.1.0-native-src/unix/native/java.c

commons-daemon-1.1.0-native-src/unix/native/replace.h

commons-daemon-1.1.0-native-src/unix/native/help.h

commons-daemon-1.1.0-native-src/unix/native/signals.c

commons-daemon-1.1.0-native-src/unix/native/jsvc-unix.c

commons-daemon-1.1.0-native-src/unix/native/location.h

commons-daemon-1.1.0-native-src/unix/native/locks.c

commons-daemon-1.1.0-native-src/unix/native/home.h

commons-daemon-1.1.0-native-src/unix/native/debug.h

commons-daemon-1.1.0-native-src/unix/native/java.h

commons-daemon-1.1.0-native-src/unix/native/version.h

commons-daemon-1.1.0-native-src/unix/native/arguments.h

commons-daemon-1.1.0-native-src/unix/native/dso.h

commons-daemon-1.1.0-native-src/unix/native/home.c

commons-daemon-1.1.0-native-src/unix/native/Makefile.in

commons-daemon-1.1.0-native-src/unix/native/location.c

commons-daemon-1.1.0-native-src/unix/native/signals.h

commons-daemon-1.1.0-native-src/unix/native/dso-dlfcn.c

commons-daemon-1.1.0-native-src/unix/native/dso-dyld.c

commons-daemon-1.1.0-native-src/unix/native/jsvc.h

commons-daemon-1.1.0-native-src/unix/native/arguments.c

commons-daemon-1.1.0-native-src/unix/Makedefs.in

commons-daemon-1.1.0-native-src/unix/support/config.guess

commons-daemon-1.1.0-native-src/unix/support/apsupport.m4

commons-daemon-1.1.0-native-src/unix/support/config.sub

commons-daemon-1.1.0-native-src/unix/support/apfunctions.m4

commons-daemon-1.1.0-native-src/unix/support/apjava.m4

commons-daemon-1.1.0-native-src/unix/Makefile.in

commons-daemon-1.1.0-native-src/unix/configure

commons-daemon-1.1.0-native-src/unix/man/fetch.sh

commons-daemon-1.1.0-native-src/unix/support/mkdist.sh

commons-daemon-1.1.0-native-src/unix/support/install.sh

commons-daemon-1.1.0-native-src/unix/support/buildconf.sh

commons-daemon-1.1.0-native-src/windows/

commons-daemon-1.1.0-native-src/windows/apps/

commons-daemon-1.1.0-native-src/windows/apps/prunmgr/

commons-daemon-1.1.0-native-src/windows/apps/prunsrv/

commons-daemon-1.1.0-native-src/windows/include/

commons-daemon-1.1.0-native-src/windows/resources/

commons-daemon-1.1.0-native-src/windows/xdocs/

commons-daemon-1.1.0-native-src/windows/src/

commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.c

commons-daemon-1.1.0-native-src/windows/apps/prunmgr/Makefile

commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.manifest

commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.h

commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.manifest

commons-daemon-1.1.0-native-src/windows/apps/prunsrv/Makefile

commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.c

commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.h

commons-daemon-1.1.0-native-src/windows/include/console.h

commons-daemon-1.1.0-native-src/windows/include/cmdline.h

commons-daemon-1.1.0-native-src/windows/include/apxwin.h

commons-daemon-1.1.0-native-src/windows/include/Makefile.inc

commons-daemon-1.1.0-native-src/windows/include/javajni.h

commons-daemon-1.1.0-native-src/windows/include/gui.h

commons-daemon-1.1.0-native-src/windows/include/handles.h

commons-daemon-1.1.0-native-src/windows/include/service.h

commons-daemon-1.1.0-native-src/windows/include/registry.h

commons-daemon-1.1.0-native-src/windows/include/log.h

commons-daemon-1.1.0-native-src/windows/include/rprocess.h

commons-daemon-1.1.0-native-src/windows/resources/license.rtf

commons-daemon-1.1.0-native-src/windows/xdocs/index.xml

commons-daemon-1.1.0-native-src/windows/src/javajni.c

commons-daemon-1.1.0-native-src/windows/src/mclib.h

commons-daemon-1.1.0-native-src/windows/src/console.c

commons-daemon-1.1.0-native-src/windows/src/service.c

commons-daemon-1.1.0-native-src/windows/src/handles.c

commons-daemon-1.1.0-native-src/windows/src/utils.c

commons-daemon-1.1.0-native-src/windows/src/registry.c

commons-daemon-1.1.0-native-src/windows/src/mclib.c

commons-daemon-1.1.0-native-src/windows/src/private.h

commons-daemon-1.1.0-native-src/windows/src/cmdline.c

commons-daemon-1.1.0-native-src/windows/src/gui.c

commons-daemon-1.1.0-native-src/windows/src/rprocess.c

commons-daemon-1.1.0-native-src/windows/src/log.c

commons-daemon-1.1.0-native-src/windows/README

commons-daemon-1.1.0-native-src/windows/apps/prunmgr/prunmgr.rc

commons-daemon-1.1.0-native-src/windows/apps/prunsrv/prunsrv.rc

commons-daemon-1.1.0-native-src/windows/resources/susers.bmp

commons-daemon-1.1.0-native-src/windows/resources/commons.bmp

commons-daemon-1.1.0-native-src/windows/resources/procruns.ico

commons-daemon-1.1.0-native-src/windows/resources/procrunr.ico

commons-daemon-1.1.0-native-src/windows/resources/procrunw.ico

[root@localhost jsvc]# ls

commons-daemon-1.1.0.jar  commons-daemon-1.1.0-native-src  commons-daemon-1.1.0-native-src.tar.gz

进入commons-daemon-1.1.0-native-src/unix目录

[root@localhost jsvc]# cd *src

[root@localhost commons-daemon-1.1.0-native-src]# ls

LICENSE.txt  NOTICE.txt  README  RELEASE-NOTES.txt  unix  windows

[root@localhost commons-daemon-1.1.0-native-src]# cd unix

[root@localhost unix]# ls

configure  configure.in  INSTALL.txt  Makedefs.in  Makefile.in  man  native  support

查找当前环境java_home目录

[root@localhost unix]# find / -name java

/etc/pki/ca-trust/extracted/java

/etc/pki/java

/etc/alternatives/java

/var/lib/alternatives/java

/usr/bin/java

/usr/local/zookeeper-3.4.12/contrib/loggraph/src/java

/usr/local/zookeeper-3.4.12/contrib/fatjar/src/java

/usr/local/zookeeper-3.4.12/contrib/ZooInspector/src/java

/usr/local/zookeeper-3.4.12/recipes/election/src/java

/usr/local/zookeeper-3.4.12/recipes/queue/src/java

/usr/local/zookeeper-3.4.12/recipes/lock/src/java

/usr/local/zookeeper-3.4.12/src/contrib/rest/src/java

/usr/local/zookeeper-3.4.12/src/contrib/loggraph/src/java

/usr/local/zookeeper-3.4.12/src/contrib/zooinspector/src/java

/usr/local/zookeeper-3.4.12/src/contrib/fatjar/src/java

/usr/local/zookeeper-3.4.12/src/recipes/election/src/java

/usr/local/zookeeper-3.4.12/src/recipes/queue/src/java

/usr/local/zookeeper-3.4.12/src/recipes/lock/src/java

/usr/local/zookeeper-3.4.12/src/java

/usr/java

/usr/java/jdk1.8.0_171-amd64/bin/java

/usr/java/jdk1.8.0_171-amd64/jre/bin/java

检查java环境是否正确

[root@localhost unix]# ./configure --with-java=/usr/java/jdk1.8.0_171-amd64

*** Current host ***

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking cached host system type... ok

*** C-Language compilation tools ***

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking for ranlib... ranlib

checking for strip... strip

*** Host support ***

checking C flags dependant on host system type... ok

*** Java compilation tools ***

checking JAVA_HOME... /usr/java/jdk1.8.0_171-amd64

checking for JDK os include directory...  linux

gcc flags added

checking how to run the C preprocessor... gcc -E

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking sys/capability.h usability... no

checking sys/capability.h presence... no

checking for sys/capability.h... no

configure: WARNING: cannot find headers for libcap

*** Writing output files ***

configure: creating ./config.status

config.status: creating Makefile

config.status: creating Makedefs

config.status: creating native/Makefile

*** All done ***

Now you can issue "make"

输入make命令进行编译

[root@localhost unix]# make

(cd native; make  all)

make[1]: Entering directory `/opt/jsvc/commons-daemon-1.1.0-native-src/unix/native'

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c jsvc-unix.c -o jsvc-unix.o

jsvc-unix.c: In function ‘run_controller’:

jsvc-unix.c:1304:20: warning: assignment from incompatible pointer type [enabled by default]

     act.sa_handler = controller;

                    ^

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c arguments.c -o arguments.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c debug.c -o debug.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c dso-dlfcn.c -o dso-dlfcn.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c dso-dyld.c -o dso-dyld.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c help.c -o help.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c home.c -o home.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c java.c -o java.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c location.c -o location.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c replace.c -o replace.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c locks.c -o locks.o

gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes   -I/usr/java/jdk1.8.0_171-amd64/include -I/usr/java/jdk1.8.0_171-amd64/include/linux -c signals.c -o signals.o

ar cr libservice.a arguments.o debug.o dso-dlfcn.o dso-dyld.o help.o home.o java.o location.o replace.o locks.o signals.o

ranlib libservice.a

gcc   jsvc-unix.o libservice.a -ldl -lpthread -o ../jsvc

make[1]: Leaving directory `/opt/jsvc/commons-daemon-1.1.0-native-src/unix/native'

编译完成,查看目录会生成jsvc文件,将jsvc拷贝到上级目录

[root@localhost unix]# ls

config.log  config.nice  config.status  configure  configure.in  INSTALL.txt  jsvc  Makedefs  Makedefs.in  Makefile  Makefile.in  man  native  support

[root@localhost unix]# cp jsvc ../../

以上是关于安装jsvc的主要内容,如果未能解决你的问题,请参考以下文章

Jsvc安装,配置 常规用户使用tomcat的80端口

在 CentOS 6.x 上安装 jsvc 1.0.15

centos7安装tomcat7使用jsvc做守护进程

使用jsvc启动tomcat

与仅使用 systemd 相比,我从 JSVC 获得啥好处?

开发利器_Jsvc.利用Jsvc实现Tomcat以普通用户运行监听80端口?