在Linux中部署Java web程序

一:安装jdk

  • 使用 yum list 搜索 jdk 软件包,找到带有 devel 后缀的文件,这才是要安装的软件包。

  • 注意:安装 jdk1.8
    在这里插入图片描述

  • yum install java-1.8.0-openjdk-devel.x86_64
    在这里插入图片描述

提示安装成功,输入 javac 可以看到 javac 的选项,说明安装成功。

二:安装tomcat

  • tomcat 是跨平台的程序,在tomcat官网上下载好压缩包,解压缩即可。
  • 到tomcat官网上复制 tomcat8 压缩包的下载地址。https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.zip
    在这里插入图片描述
    在这里插入图片描述
    可以看到压缩包下载好了。
  • 通过 unzip 命令来解压缩
    在这里插入图片描述

在这里插入图片描述
得到解压之后的目录
在这里插入图片描述

  • 启动 tomcat :sh startup.sh
    在这里插入图片描述
    启动 tomcat 发现没有权限。
    执行 chmod +x *.sh 给 .sh 加上可执行权限
    在这里插入图片描述

通过 ps 或者 netstat 来验证效果:证明tomcat启动成功,端口为默认的8080。
在这里插入图片描述
在这里插入图片描述

通过浏览器访问云服务器的公网 IP,并没有在 8080端口访问到 tomcat的欢迎页面。
修改云服务器的“安全组”或者“防火墙”规则。
在这里插入图片描述

在这里插入图片描述
三:安装 MariaDB

1.安装

安装 mariadb 服务

# yum install -y mariadb-server

安装 mariadb 命令行客户端

# yum install -y mariadb

安装 mariadb C library

# yum install -y mariadb-libs

安装 mariadb 开发包

# yum install -y mariadb-devel

2.更改配置

更改 /etc/my.cnf.d/client.cnf 文件
[client] 下加一行配置 default-character-set = utf8

#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#


[client]
default-character-set = utf8

# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]

更改 /etc/my.cnf.d/mysql-clients.cnf 文件

[mysql] 下加一行配置 default-character-set=utf8

#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#

[mysql]
default-character-set = utf8

[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]

更改 /etc/my.cnf.d/server.cnf 配置

[mysqld] 下加配置

collation-server = utf8_general_ci

init-connect=‘SET NAMES utf8’

character-set-server = utf8

sql-mode = TRADITIONAL

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8

sql-mode = TRADITIONAL

# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

[mariadb-5.5]

3.启动

启动服务

# systemctl start mariadb

设置服务开启自启动

# systemctl enable mariadb

查看服务状态

# systemctl status mariadb

在这里插入图片描述
四:进入数据库,将 sql 语句进行执行

五:将项目的 war 包放到 tomcat 的 webapps 目录下

war包会在tomcat服务器下自动解压缩成同名目录。

在这里插入图片描述

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值