Linux CentOS下部署Java Web项目

本文讲解如何在Linux CentOS下部署Java Web项目的步骤。

一、环境准备:

(1)Linux CentOS

(2)apache-tomcat-9.0.10

(3)XShell

二、启动tomcat

1、启动Tomcat

进入 apache-tomcat-9.0.10 下的 bin 目录下

输入:  ./catalina.sh start

[root@izuf6famz0x92jd98na1kiz bin]# ./catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0./temp
Using JRE_HOME: /usr/java/jdk1..0_171
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-9.0./bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-9.0./bin/tomcat-juli.jar
Tomcat started.

2、查看 tomcat 启动日志[可选]

进入 apache-tomcat-9.0.10/logs 下

[root@izuf6famz0x92jd98na1kiz apache-tomcat-9.0.]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@izuf6famz0x92jd98na1kiz apache-tomcat-9.0.]# cd logs
[root@izuf6famz0x92jd98na1kiz logs]# ls
catalina.--.log host-manager.--.log localhost.--.log manager.--.log
catalina.--.log host-manager.--.log localhost_access_log.--.txt manager.--.log
catalina.out localhost.--.log localhost_access_log.--.txt

执行 cat catalina.out

注: ./catalina.sh start 和 ./startup.sh 都能启动tomcat。使用 ./catalina.sh stop 或 ./shutdown.sh 停止tomcat。

可以查看 tomcat 启动日志:

[root@izuf6famz0x92jd98na1kiz logs]# cat catalina.out
-Jul- ::03.012 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.
-Jul- ::03.013 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun :: UTC
-Jul- ::03.013 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.10.0
-Jul- ::03.013 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
-Jul- ::03.013 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.-693.2..el7.x86_64
-Jul- ::03.014 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
-Jul- ::03.014 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/java/jdk1..0_171/jre
-Jul- ::03.014 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_171-b11
-Jul- ::03.014 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
-Jul- ::03.014 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.
……省略-Jul- ::43.147 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/apache-tomcat-9.0./webapps/manager] has finished in [] ms
-Jul- ::43.147 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/apache-tomcat-9.0./webapps/host-manager]
-Jul- ::43.187 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/apache-tomcat-9.0./webapps/host-manager] has finished in [] ms
-Jul- ::43.198 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
-Jul- ::43.209 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
-Jul- ::43.210 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in ms

3、访问浏览器,验证tomcat启动成功

Linux CentOS下部署Java Web项目

二、上传要部署项目文件到服务器

1、安装上传文件到 Linux 中的工具软件

lrzsz

安装指令如下:

yum install lrzsz

[root@izuf6famz0x92jd98na1kiz download]# yum install lrzsz
Loaded plugins: fastestmirror
base | 3.6 kB ::
epel | 3.2 kB ::
extras | 3.4 kB ::
updates | 3.4 kB ::
(/): base//x86_64/group_gz | kB ::
(/): epel/x86_64/group_gz | kB ::
(/): epel/x86_64/updateinfo | kB ::
(/): extras//x86_64/primary_db | kB ::
(/): epel/x86_64/primary | 3.5 MB ::
(/): base//x86_64/primary_db | 5.9 MB ::
(/): updates//x86_64/primary_db | 2.7 MB ::
Determining fastest mirrors
epel /
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 :0.12.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
lrzsz x86_64 0.12.-.el7 base k Transaction Summary
=============================================================================================================================
Install Package Total download size: k
Installed size: k
Is this ok [y/d/N]:

输入 "y"

Is this ok [y/d/N]: y
Downloading packages:
lrzsz-0.12.-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lrzsz-0.12.-.el7.x86_64 /
Verifying : lrzsz-0.12.-.el7.x86_64 / Installed:
lrzsz.x86_64 :0.12.-.el7 Complete!

验证是否安装成功:

[root@izuf6famz0x92jd98na1kiz download]# rpm -qa|grep lrzsz
lrzsz-0.12.-.el7.x86_64

出现如上,即是安装成功。

2、将项目部署文件上传到服务器

(1)使用 lrzsz 上传文件到服务器

输入 rz ,即弹出 本地电脑的文件选择框,选择要上传到服务器的文件

Linux CentOS下部署Java Web项目

(2)选择要部署项目 的 war 文件

windows 下的文件:

Linux CentOS下部署Java Web项目

上传到 阿里云的 linux服务器上:

Linux CentOS下部署Java Web项目

3、ls指令查看当前目录

Linux CentOS下部署Java Web项目

三、部署项目

1、将打包好的war包上传到tomcat服务器的webapps目录

[root@izuf6famz0x92jd98na1kiz webapps]# cp /usr/download/WeChatJPro_01.war /usr/local/tomcat/apache-tomcat-9.0./webapps
[root@izuf6famz0x92jd98na1kiz webapps]# ls
docs examples host-manager manager ROOT WeChatJPro_01 WeChatJPro_01.war

Linux CentOS下部署Java Web项目

可以发现Tomcat服务器自动解压缩war包

Linux CentOS下部署Java Web项目

2、在浏览器*问部署的项目

浏览器地址栏输入: http://IP地址:8080/项目名

Linux CentOS下部署Java Web项目

最终:成功的在阿里云ECS 的 Linux CentOS服务器上部署好Java Web项目!

 扫个红包吧!

Linux CentOS下部署Java Web项目

Donate捐赠

如果我的文章帮助了你,可以赞赏我 1 元给我支持,让我继续写出更好的内容)

Linux CentOS下部署Java Web项目   Linux CentOS下部署Java Web项目

(微信)                                        (支付宝)

微信/支付宝 扫一扫

上一篇:python scrapy版 极客学院爬虫V2


下一篇:如何在tomcat中如何部署java EE项目