一:安装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服务器下自动解压缩成同名目录。