tomcat 与 nginx 配置

11-11 tomcat 部署 & 搭建

配置 mysql

首先确保环境中 mysql 正常运行

创建数据库,导入数据

这里使用 navicat,通过远程登陆的方式导入

  • 配置 mysql 远程登陆
1
2
3
4
5
6
# 可选 修改默认的 mysql 密码
SET PASSWORD FOR root@localhost = '密码';
# 配置远程登陆
grant all privileges on *.* to 'root'@'%' identified by 'root';
flush privileges;
set password for "root"@"%" = '密码';
  • 使用 navicat 进行远程连接

关闭防火墙

1
sudo systemctl stop firewalld.service

创建数据库

数据库名: ruoyi

字符集: uft8

排序规则:留空即可

导入数据

右键 创建好的数据库,选择 运行 SQL 文件… ,分别选择两个 sql 文件执行即可。

配置 tomcat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 解压安装包
tar -zxvf apache-tomcat.gz
# 创建软链接(可选
ln -s apache-tomcat-9.0.68 tomcat
# 环境变量
vim /etc/profile
# 添加下面两行
export CAT_HOME=/root/11-11/tomcat
export PATH=$PATH:$CAT_HOME:bin
# 刷新
source /etc/profile
# 将 war 包复制至 tomcat 目录
cp ruoyi-admin.war /tomcat/webapps/
# 启动
./startup.sh

配置 nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 解压 pcre.tar.gz
tar -zxvf tar.gz
# 进入解压好的 pcre 目录
cd pcre-8.40/
# 编译安装
./configure
make
# 安装其他依赖
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
# 解压 nginx
tar -zxvf nginx.tar.gz
# 进入解压好的 nginx 目录
cd nginx/
# 编译安装
./configure
make && make install

配置 nginx

配置文件 /usr/local/nginx/conf 中,名为 nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
listen 80;
#server_name localhost;
# 修改为 8080
server_name 127.0.0.1:8080;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
# 配置转发
proxy_pass http://127.0.0.1:8080;
}

启动 ng

1
2
cd /usr/local/nginx/sbin
./nginx