1、上传安装包
部署到 /usr/local/,创建好文件夹、目录。
2、解压缩
tar -zxvf apache-tomcat-9.0.10.tar.gz
3、启动tomcat
进入tomcat下的bin目录
./catalina.sh start
注: ./catalina.sh start 和 ./startup.sh 都能启动tomcat。
使用 ./catalina.sh stop 或 ./shutdown.sh 停止tomcat。
4、通过浏览器访问
5、Tomcat配置服务和自启动
到tomcat的bin目录中把catalina.sh复制到/etc/init.d里并命名为tomcat
cp /usr/local/tomcat/apache-tomcat-9.0.10/bin/catalina.sh /etc/init.d/tomcat
编辑此文件
cd /etc/init.d
ls
显示结果:aegis agentwatch functions netconsole network README tomcat
vi tomcat
加入如下配置:
JAVA_HOME=/usr/java/jdk1.8.0
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/local/apache-tomcat
给这个脚本与权限
chmod 755 tomcat
添加tomcat服务这里用chkconfig
chkconfig --add tomcat
如果这里出现提
insserv: warning: script 'tomcat' missing LSB tags and overrides
insserv: There is a loop between service nginx and tomcat if stopped
insserv: loop involving service tomcat at depth 2
insserv: loop involving service nginx at depth 1
insserv: Stopping tomcat depends on nginx and therefore on system facility `$all' which can not be true!
insserv: exiting now without changing boot order!
则需要安装chkconfig安装方法
apt-get install chkconfig
就可以如出现以下表示成功
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
也可以在输入以下命令查看一下
chkconfig --list tomcat
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如果345 为关闭状态。执行如下命令设置tomcat为开机自启动。
chkconfig tomcat on
启动一下看看
service tomcat start
Using CATALINA_BASE: /usr/local/apache-tomcat
Using CATALINA_HOME: /usr/local/apache-tomcat
Using CATALINA_TMPDIR: /usr/local/apache-tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_07
Using CLASSPATH: /usr/local/apache-tomcat/bin/bootstrap.jar:/usr/local/apache-tomcat/bin/tomcat-juli.jar
启动,停止,重启
service tomcat start
service tomcat stop
service tomcat restart