目录
一、下载commons-daemon
Daemon – Download Apache Commons Daemon
二、解压安装
1.上传至服务器 ,执行解压命令
tar -xzvf commons-daemon-1.3.3-src.tar.gz
2.进入目录unix
cd commons-daemon-1.3.3-src/src/native/unix/
[root@centos-tianmen unix]# ll
总用量 172
-rwxrwxr-x. 1 root root 147655 9月 18 21:49 configure
-rw-r--r--. 1 root root 5038 9月 18 21:49 configure.in
-rw-r--r--. 1 root root 2598 9月 18 21:49 INSTALL.txt
-rw-r--r--. 1 root root 1081 9月 18 21:49 Makedefs.in
-rw-r--r--. 1 root root 1110 9月 18 21:49 Makefile.in
drwxr-xr-x. 2 root root 58 3月 19 23:11 man
drwxr-xr-x. 2 root root 4096 3月 19 23:11 native
drwxr-xr-x. 2 root root 141 3月 19 23:11 support
3.配置
./configure --with-java=/你的jdk安装目录
4.make
make
5.验证
./jsvc --help
示例:
[root@centos-tianmen unix]# ./configure --with-java=/apphome/jdk1.8.0_361
*** 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 the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... -std=gnu11
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... /apphome/jdk1.8.0_361
checking for JDK os include directory... linux
gcc flags added
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
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"
[root@centos-tianmen unix]# make
(cd native; make all)
make[1]: 进入目录“/apphome/commons-daemon-1.3.3-src/src/native/unix/native”
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c jsvc-unix.c -o jsvc-unix.o
jsvc-unix.c: 在函数‘run_controller’中:
jsvc-unix.c:1311:20: 警告:从不兼容的指针类型赋值 [默认启用]
act.sa_handler = controller;
^
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c arguments.c -o arguments.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c debug.c -o debug.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c dso-dlfcn.c -o dso-dlfcn.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c dso-dyld.c -o dso-dyld.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c help.c -o help.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c home.c -o home.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c java.c -o java.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c location.c -o location.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c replace.c -o replace.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/include/linux -c locks.c -o locks.o
gcc -std=gnu11 -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU=\"amd64\" -Wall -Wstrict-prototypes -I/apphome/jdk1.8.0_361/include -I/apphome/jdk1.8.0_361/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 -std=gnu11 jsvc-unix.o libservice.a -ldl -lpthread -o ../jsvc
make[1]: 离开目录“/apphome/commons-daemon-1.3.3-src/src/native/unix/native”
[root@centos-tianmen unix]# ./jsvc --help
Usage: jsvc [-options] class [args...]
Where options include:
-help | --help | -?
show this help page (implies -nodetach)
-jvm <JVM name>
use a specific Java Virtual Machine. Available JVMs:
'server'
...
6.复制jsvc到指定目录
cp jsvc /apphome/
7.建立软连接
ln /apphome/jsvc /usr/bin/jsvc