tomcat安装_tomcat--daemon模式安装

检查

java –version查看jdk环境

[root@localhost ~]# java -version-bash: /usr/bin/java: No such file or directory
  • not found说明当前服务器没有JDK环境,需要安装JDK。

进入tomcat/bin目录下查看是否存在commons-daemon-native.tar.gz包

[root@localhost ~]# cd apache-tomcat-9.0.33/bin/[root@localhost bin]# lsbootstrap.jar  catalina-tasks.xml  commons-daemon.jar            configtest.sh  digest.sh     setclasspath.bat  shutdown.sh  tomcat-juli.jar       tool-wrapper.shcatalina.bat   ciphers.bat         commons-daemon-native.tar.gz  daemon.sh      makebase.bat  setclasspath.sh   startup.bat  tomcat-native.tar.gz  version.batcatalina.sh    ciphers.sh          configtest.bat                digest.bat     makebase.sh   shutdown.bat      startup.sh   tool-wrapper.bat      version.sh[root@localhost bin]#

若不存在可以在相同版本的tomcat中拷贝到当前tomcat/bin目录下,或者去新的tomcat中寻找,也可以去http://www.apache.org/dist/commons/daemon/source/下载

安装

创建tomcat用户和tomcat组

[root@localhost ~]# groupadd tomcat[root@localhost ~]# useradd -g tomcat -s /usr/sbin/nologin tomcat

tar命令解压commons-daemon-native.tar.gz

tar -zxvf commons-daemon-native.tar.gz

若出现-bash: tar: command not found错误,可以使用yum安装tar

yum install tar -y

解压完毕后进入commons-daemon-1.2.2-native-src/unix/

[root@localhost bin]# cd commons-daemon-1.2.2-native-src/unix/[root@localhost unix]# lsconfigure  configure.in  INSTALL.txt  Makedefs.in  Makefile.in  man  native  support[root@localhost unix]#

执行./configure命令

./configure

若出现下面错误

[root@localhost unix]# ./configure*** Current host ***checking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-gnuchecking cached host system type... ok*** C-Language compilation tools ***checking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/root/apache-tomcat-9.0.33/bin/commons-daemon-1.2.2-native-src/unix':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details
  • 该错误说明当前环境没有c编辑器,可以使用yum安装gcc来解决
yum install gcc -y

安装gcc后。重新执行,结果如下图

[root@localhost unix]# ./configure*** Current host ***checking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-gnuchecking cached host system type... ok*** C-Language compilation tools ***checking for gcc... gccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking for ranlib... ranlibchecking for strip... strip*** Host support ***checking C flags dependant on host system type... ok*** Java compilation tools ***checking for JDK location... configure: error: Java Home not defined. Rerun with --with-java=... parameter
  • 若已经安装JDK需要使用–with-java参数指定JDK路径
  • 若未安装JDK需要先安装JDK再使用–with-java参数指定JDK路径
  • openJDK的安装位置可以在/usr/lib/jvm/目录下找到

加上–with-java参数再次执行

[root@localhost unix]# ./configure --with-java=/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64*** Current host ***checking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-gnuchecking cached host system type... ok*** C-Language compilation tools ***checking for gcc... gccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking for ranlib... ranlibchecking for strip... strip*** Host support ***checking C flags dependant on host system type... ok*** Java compilation tools ***checking JAVA_HOME... /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64checking for JDK os include directory... Cannot find jni_md.h in /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/configure: error: You should retry --with-os-type=SUBDIR
  • /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64是我的JDK路径
  • 需要加上–with-os-type参数指定JDK/include中的jni_md.h文件

若JDK内不存在include文件夹或jni_md.h文件,可以使用yum安装当前JDK的管理包,若存在跳过此步骤。具体操作如下

[root@localhost unix]# java -versionopenjdk version "11.0.5" 2019-10-15 LTSOpenJDK Runtime Environment 18.9 (build 11.0.5+10-LTS)OpenJDK 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode, sharing)[root@localhost unix]# yum search *jdk*Last metadata expiration check: 0:55:15 ago on Tue 24 Mar 2020 10:46:41 PM CST.=============================================================================== Name & Summary Matched: *jdk* ===============================================================================java-11-openjdk-demo.x86_64 : OpenJDK Demos 11java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos 8java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11java-11-openjdk-src.x86_64 : OpenJDK Source Bundle 11java-11-openjdk.x86_64 : OpenJDK Runtime Environment 11java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle 8java-11-openjdk.x86_64 : OpenJDK Runtime Environment 11copy-jdk-configs.noarch : JDKs configuration files copiercopy-jdk-configs.noarch : JDKs configuration files copierjava-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentationjava-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentationjava-11-openjdk-devel.x86_64 : OpenJDK Development Environment 11java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8java-11-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 11java-11-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 11java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK 8 accessibility connectorjava-1.8.0-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 8java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in single archivejava-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in single archive================================================================================== Summary Matched: *jdk* ===================================================================================icedtea-web.noarch : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation[root@localhost unix]# yum install java-11-openjdk-devel.x86_64 -yLast metadata expiration check: 0:55:32 ago on Tue 24 Mar 2020 10:46:41 PM CST.Dependencies resolved.============================================================================================================================================================================================= Package                                             Architecture                         Version                                              Repository                               Size=============================================================================================================================================================================================Installing: java-11-openjdk-devel                               x86_64                               1:11.0.5.10-2.el8_1                                  AppStream                               3.3 MTransaction Summary=============================================================================================================================================================================================Install  1 PackageTotal download size: 3.3 MInstalled size: 5.3 MDownloading Packages:java-11-openjdk-devel-11.0.5.10-2.el8_1.x86_64.rpm                                                                                                           641 kB/s | 3.3 MB     00:05---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                                        558 kB/s | 3.3 MB     00:06Running transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transaction  Preparing        :                                                                                                                                                                     1/1  Installing       : java-11-openjdk-devel-1:11.0.5.10-2.el8_1.x86_64                                                                                                                    1/1  Running scriptlet: java-11-openjdk-devel-1:11.0.5.10-2.el8_1.x86_64                                                                                                                    1/1  Verifying        : java-11-openjdk-devel-1:11.0.5.10-2.el8_1.x86_64                                                                                                                    1/1Installed:  java-11-openjdk-devel-1:11.0.5.10-2.el8_1.x86_64Complete![root@localhost unix]#

安装JDK-devel包后,重新执行

[root@localhost unix]# ./configure --with-java=/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64*** Current host ***checking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-gnuchecking cached host system type... ok*** C-Language compilation tools ***checking for gcc... gccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking for ranlib... ranlibchecking for strip... strip*** Host support ***checking C flags dependant on host system type... ok*** Java compilation tools ***checking JAVA_HOME... /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64checking for JDK os include directory...  linuxgcc flags addedchecking how to run the C preprocessor... gcc -Echecking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking sys/capability.h usability... nochecking sys/capability.h presence... nochecking for sys/capability.h... noconfigure: WARNING: cannot find headers for libcap*** Writing output files ***configure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating Makedefsconfig.status: creating native/Makefile*** All done ***Now you can issue "make"[root@localhost unix]#

出现All done说明可以进行编译安装了若还存在configure: error: You should retry --with-os-type=SUBDIR信息,可以使用find / -name "jni_md.h"找到路径,指定–with-os-type。出现All done可进行编译

执行make进行编译

[root@localhost unix]# make-bash: make: command not found[root@localhost unix]#
  • command not found需要安装使用yun安装make
yum install make -y

安装make包后重新执行make

[root@localhost unix]# make(cd native; make  all)make[1]: Entering directory '/root/apache-tomcat-9.0.33/bin/commons-daemon-1.2.2-native-src/unix/native'gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c jsvc-unix.c -o jsvc-unix.ojsvc-unix.c: In function ‘run_controller’:jsvc-unix.c:1293:20: warning: assignment to ‘__sighandler_t’ {aka ‘void (*)(int)’} from incompatible pointer type ‘void (*)(int,  siginfo_t *, void *)’ {aka ‘void (*)(int,  struct  *, void *)’} [-Wincompatible-pointer-types]     act.sa_handler = controller;                    ^gcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c arguments.c -o arguments.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c debug.c -o debug.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c dso-dlfcn.c -o dso-dlfcn.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c dso-dyld.c -o dso-dyld.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c help.c -o help.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c home.c -o home.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c java.c -o java.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c location.c -o location.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c replace.c -o replace.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c locks.c -o locks.ogcc -g -O2 -DOS_LINUX -DDSO_DLFCN -DCPU="amd64" -Wall -Wstrict-prototypes   -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/include/linux -c signals.c -o signals.oar 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.oranlib libservice.agcc   jsvc-unix.o libservice.a -ldl -lpthread -o ../jsvcmake[1]: Leaving directory '/root/apache-tomcat-9.0.33/bin/commons-daemon-1.2.2-native-src/unix/native'[root@localhost unix]# lsconfig.log  config.nice  config.status  configure  configure.in  INSTALL.txt  jsvc  Makedefs  Makedefs.in  Makefile  Makefile.in  man  native  support[root@localhost unix]#

生成一个jsvc文件,将其复制到tomcat的bin目录

[root@localhost unix]# cp jsvc ../../[root@localhost unix]# cd ../../[root@localhost bin]# lsbootstrap.jar  catalina-tasks.xml  commons-daemon-1.2.2-native-src  configtest.bat  digest.bat  makebase.bat      setclasspath.sh  startup.bat      tomcat-native.tar.gz  version.batcatalina.bat   ciphers.bat         commons-daemon.jar               configtest.sh   digest.sh   makebase.sh       shutdown.bat     startup.sh       tool-wrapper.bat      version.shcatalina.sh    ciphers.sh          commons-daemon-native.tar.gz     daemon.sh       jsvc        setclasspath.bat  shutdown.sh      tomcat-juli.jar  tool-wrapper.sh[root@localhost bin]#

编辑daemon.sh文件,找到如下内容

test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat# Set JAVA_HOME to working JDK or JRE# JAVA_HOME=/opt/jdk-1.6.0.22

修改TOMCAT_USER=tomcat,将tomcat修改为你所需要的用户修改# JAVA_HOME=/opt/jdk-1.6.0.22,路径为你的JDK路径修改后的结果如下

test ".$TOMCAT_USER" = . && TOMCAT_USER=tomcat# Set JAVA_HOME to working JDK or JREJAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64
  • tomcat是我创建的用户
  • /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64是我的JDK路径

修改tomcat的所属用户和组,并赋予daemon.sh文件可执行权限

[root@localhost bin]# cd[root@localhost ~]# chown -R tomcat:tomcat apache-tomcat-9.0.33[root@localhost ~]# chmod a+x apache-tomcat-9.0.33/bin/daemon.sh

到此所有的配置都完成了,若tomcat中项目需要读取其他文件夹,请确认该文件夹的权限是否满足你的需求

验证

使用apache-tomcat-9.0.33/bin/daemon.sh run命令启动[root@localhost ~]# apache-tomcat-9.0.33/bin/daemon.sh run25-Mar-2020 00:43:13.119 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/9.0.3325-Mar-2020 00:43:13.122 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Mar 11 2020 09:31:38 UTC25-Mar-2020 00:43:13.122 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.33.025-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux25-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            4.18.0-147.el8.x86_6425-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd6425-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_6425-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           11.0.5+10-LTS25-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation25-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /root/apache-tomcat-9.0.3325-Mar-2020 00:43:13.123 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /root/apache-tomcat-9.0.3325-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/root/apache-tomcat-9.0.33/conf/logging.properties25-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager25-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=25-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/root/apache-tomcat-9.0.3325-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/root/apache-tomcat-9.0.3325-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/root/apache-tomcat-9.0.33/temp25-Mar-2020 00:43:13.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcommons.daemon.process.id=2121425-Mar-2020 00:43:13.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcommons.daemon.process.parent=2120825-Mar-2020 00:43:13.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcommons.daemon.version=1.2.225-Mar-2020 00:43:13.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: abort25-Mar-2020 00:43:13.159 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/lib/server:/usr/lib/jvm/java-11-openjdk-11.0.5.10-2.el8_1.x86_64/lib:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]25-Mar-2020 00:43:13.963 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]25-Mar-2020 00:43:14.051 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1,466] milliseconds25-Mar-2020 00:43:14.202 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]25-Mar-2020 00:43:14.202 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.33]25-Mar-2020 00:43:14.237 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/root/apache-tomcat-9.0.33/webapps/ROOT]25-Mar-2020 00:43:14.926 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/root/apache-tomcat-9.0.33/webapps/ROOT] has finished in [688] ms25-Mar-2020 00:43:14.926 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/root/apache-tomcat-9.0.33/webapps/docs]25-Mar-2020 00:43:14.979 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/root/apache-tomcat-9.0.33/webapps/docs] has finished in [53] ms25-Mar-2020 00:43:14.979 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/root/apache-tomcat-9.0.33/webapps/examples]25-Mar-2020 00:43:15.624 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/root/apache-tomcat-9.0.33/webapps/examples] has finished in [645] ms25-Mar-2020 00:43:15.625 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/root/apache-tomcat-9.0.33/webapps/host-manager]25-Mar-2020 00:43:15.738 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/root/apache-tomcat-9.0.33/webapps/host-manager] has finished in [113] ms25-Mar-2020 00:43:15.738 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/root/apache-tomcat-9.0.33/webapps/manager]25-Mar-2020 00:43:15.806 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/root/apache-tomcat-9.0.33/webapps/manager] has finished in [68] ms25-Mar-2020 00:43:15.836 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]25-Mar-2020 00:43:15.939 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [1,887] milliseconds

启动后可以在浏览器中访问到tomcat,若访问不到检查防火墙的中是否添加了tomcat端口,防火墙是否开启

45e273a831f5778d72024e0248fb8ec2.png

动态效果图

c965a9d6e61e3095722147221c5a21a5.gif

daemon模式的基本操作

bin/daemon.sh start 启动bin/daemon.sh stop 停止bin/daemon.sh version 查看版本logs/catalina-daemon.out 查看日志
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 首先,您需要在CentOS 7上安装Java Development Kit(JDK)。可以使用以下命令安装OpenJDK: ``` sudo yum install java-1.8.0-openjdk-devel ``` 确认安装成功: ``` java -version javac -version ``` 2. 接下来,您需要下载并安装Tomcat。您可以在Tomcat官方网站(https://tomcat.apache.org/download-10.cgi)上找到最新的Tomcat版本。选择一个适合您的需求的版本。 3. 使用wget命令下载Tomcat二进制文件(将URL替换为您选择的Tomcat版本): ``` wget https://downloads.apache.org/tomcat/tomcat-10/v10.0.10/bin/apache-tomcat-10.0.10.tar.gz ``` 4. 解压下载的文件: ``` tar -zxvf apache-tomcat-10.0.10.tar.gz ``` 5. 将解压后的Tomcat目录移动到适当的位置,例如`/opt`目录: ``` sudo mv apache-tomcat-10.0.10 /opt/tomcat ``` 6. 接下来,您需要创建一个用于启动Tomcat的用户。运行以下命令: ``` sudo groupadd tomcat sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat ``` 7. 设置Tomcat目录的所有者为创建的用户: ``` sudo chown -R tomcat:tomcat /opt/tomcat ``` 8. 配置Tomcat作为服务,创建一个Systemd服务文件。使用以下命令创建一个名为`tomcat.service`的文件: ``` sudo nano /etc/systemd/system/tomcat.service ``` 在打开的文件中,添加以下内容: ``` [Unit] Description=Apache Tomcat Web Application Container After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh User=tomcat Group=tomcat UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target ``` 9. 保存并关闭文件。 10. 启用Tomcat服务并将其设置为开机启动: ``` sudo systemctl daemon-reload sudo systemctl enable tomcat ``` 11. 启动Tomcat服务: ``` sudo systemctl start tomcat ``` 12. 您可以通过访问服务器的IP地址和Tomcat默认端口8080来验证Tomcat是否正常运行。在浏览器中输入以下URL: ``` http://服务器IP地址:8080/ ``` 如果一切正常,您将看到Tomcat的欢迎页面。 这就是在CentOS 7上安装和配置Tomcat的基本步骤。根据您的需求,您可能还需要进行其他配置,例如设置访问权限、配置SSL等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值