Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
wi1sonh committed Jun 24, 2024
1 parent 4e4ef46 commit 2b51d70
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@
6. **后台管理系统**:为商家提供商品和订单管理,数据统计等后台功能。
7. **数据分析与报告**:提供销售数据和用户行为分析,辅助商家决策。

运行截图
商家管理端运行截图

| 登录页![login](images/login.png) | 商家控制台页![control](images/control_board.png) |
| ------------------------------ | ---------------------------------------------- |

| 订单管理![login](images/s1.png) | 商品管理![login](images/s2.png) | 数据统计![login](images/s3.png) |
| - | - | - |

客户小程序运行截图:

| ![mp1](images/mp1.jpg) | ![mp2](images/mp2.jpg) | ![mp3](images/mp3.jpg) | ![mp4](images/mp4.jpg) | ![mp5](images/mp5.jpg) |
| - | - | - | - | - |

## 技术选型

### 前端
Expand Down Expand Up @@ -78,6 +86,10 @@ npm run dev

小程序端还需要启动本地 redis 数据库,连接过程和 mysql 差不多(但 redis 连接时不需要输入 username)

## 云服务器部署步骤

详见[云服务器部署文档](doc/云服务器部署文档.md)

## 前端代码说明

### vue3网页代码结构
Expand Down
167 changes: 167 additions & 0 deletions doc/云服务器部署文档.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# 云服务器部署步骤

todo: 图片还没上传。。

## Frontend

以阿里云ECS为例,通过NodeSource提供的官方包安装,自带最新npm

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

npm run build打包

```sh
cd cloudmall-vue3
npm i
npm run dev
```

## 部署后端环境

### 打包上传后端代码

IDEA打开项目工程,在application-dev.yml文件中修改datasource和redis的主机和端口,如下图

然后打开右边的maven,点击跳过测试,然后执行package

接着在你的本地就会生成一个jar包,一般在该目录的target目录下,参考下图

在cloudmall目录上传刚才我们打包好的jar包

### 配置Redis

拉取Redis镜像,默认最新版

```sh
docker pull redis
```

在cloudmall目录下创建redis目录,进入redis目录,在该目录下创建redis.conf文件

编辑redis.conf文件为如下内容

```c
#持久化存储
appendonly yes
#设置redis密码
requirepass 123456
```

创建redis容器,因为redis需要修改配置文件,我们采用外部挂载的方式会方便很多

```sh
docker run -v /home/wi1sonh/cloudmall/redis/redis.conf:/etc/redis/redis.conf \
-v /home/wi1sonh/cloudmall/redis/data:/home/wi1sonh/cloudmall \
-d --name myredis \
-p 6380:6379 \
redis:latest redis-server /etc/redis/redis.conf
```

连接测试

```sh
docker exec -it myredis redis-cli -a 123456
ping
```

### 配置MySQL

拉取MySQL镜像,默认为最新版

```sh
docker pull mysql
```

创建mysql容器,这里的镜像id需要使用`docker images`命令查看自己对应的mysql镜像id,和之前使用过的操作一样

```sh
docker run -id --name=mysql -p 3305:3306 -e MYSQL_ROOT_PASSWORD=123456 <镜像id>
```

建表

```sh
docker cp /home/wi1sonh/cloudmall/cloudmall_database.sql <容器id>:/
```

连接测试

```sh
docker exec -it mysql bash
mysql -uroot -p
show databases;
source /cloudmall_database.sql;
show tables;
exit
exit
```

### 部署后端代码

在项目jar文件所在目录下编写 DockerFile 文件

```c
#拉取jdk22版本的镜像
FROM openjdk:22-jdk-slim
#作者自己自定义
LABEL maintainer=wilson

COPY *.jar /app.jar
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' > /etc/timezone
ENTRYPOINT ["java","-jar","/app.jar"]
```

构建docker镜像,后面的 `.` 不要误删,代表在该目录工作:

`docker build -t java-cloudmall:v1.0 -f DockerFile .`

建立java容器(最好先检查容器是否全部启动,指令是docker ps)

`docker run -d -p 8081:8081 --name cloudmall java-cloudmall:v1.0 -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime`



域名DNS解析

nginx 反向代理

`sudo apt install nginx`

`sudo vim /etc/nginx/nginx.conf`

```c
server {
listen 80;
server_name cloud-mall.hwyl.run;

location / {
root html;
index index.html index.htm;
proxy_pass http://47.121.122.236:5173;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
```

测试 `nginx -t`

重启 `nginx -s reload`

修改系统时间

`ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime`

`/usr/share/zoneinfo/tzselect`

`echo "Asia/Shanghai" > /etc/timezone`

查看时间

`date`

Binary file modified images/control_board.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mp1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mp2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mp3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mp4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mp5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/s3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b51d70

Please sign in to comment.