litemall/deploy/README.md
jinghaibing 2689ecca8e
Some checks are pending
Actions / Litemall-all (11) (push) Waiting to run
Actions / Litemall-all (11.0.3) (push) Waiting to run
Actions / Litemall-all (8) (push) Waiting to run
Actions / Litemall-all (8.0.192) (push) Waiting to run
Actions / Litemall-admin (10.x) (push) Waiting to run
Actions / Litemall-admin (12.x) (push) Waiting to run
Actions / Litemall-admin (14.x) (push) Waiting to run
Actions / Litemall-vue (10.x) (push) Waiting to run
Actions / Litemall-vue (12.x) (push) Waiting to run
Actions / Litemall-vue (14.x) (push) Waiting to run
Initial commit
2025-04-14 14:25:41 +08:00

104 lines
3.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## deploy
### 项目打包
1. 在服务器或者开发机打包项目到deploy
```
cd litemall
cat ./litemall-db/sql/litemall_schema.sql > ./deploy/db/litemall.sql
cat ./litemall-db/sql/litemall_table.sql >> ./deploy/db/litemall.sql
cat ./litemall-db/sql/litemall_data.sql >> ./deploy/db/litemall.sql
cd ./litemall-admin
npm install --registry=https://registry.npm.taobao.org
npm run build:dep
cd ..
mvn clean package
cp -f ./litemall-all/target/litemall-all-*-exec.jar ./deploy/litemall/litemall.jar
```
这里的工作是:
1. 把数据库文件拷贝到deploy/db文件夹
2. 编译litemall-admin项目
3. 编译litemall-all模块同时把litemall-admin编译得到的静态文件拷贝到
litemall-all模块的static目录
2. 修改litemall文件夹下面的*.yml外部配置文件当litemall-all模块启动时会
加载外部配置文件而覆盖默认jar包内部的配置文件。
例如配置文件中一些地方需要设置成远程服务器的IP地址
此时deploy部署包结构如下
* bin
存放远程服务器运行的脚本包括deploy.sh脚本和reset.sh脚本
* db
存放litemall数据库文件
* litemall
存放远程服务器运行的代码包括litemall-all二进制可执行包和litemall外部配置文件
* util
存放开发服务器运行的脚本包括package.sh脚本和lazy.sh脚本。
由于是本地开发服务器运行,因此开发者可以不用上传到远程服务器。
### 项目部署
1. 远程服务器环境MySQL和JDK1.8)已经安装好,请确保云服务器的安全组已经允许相应的端口。
2. 导入db/litemall.sql
```bash
cd /home/ubuntu/deploy/db
mysql -h localhost -u $ROOT -p$PASSWORD < litemall.sql
```
3. 启动服务
```bash
sudo service litemall stop
sudo ln -f -s /home/ubuntu/deploy/litemall/litemall.jar /etc/init.d/litemall
sudo service litemall start
```
4. 测试是否部署成功(xxx.xxx.xxx.xxx是云服务器IP
```
http://xxx.xxx.xxx.xxx:8080/wx/index/index
http://xxx.xxx.xxx.xxx:8080/admin/index/index
http://xxx.xxx.xxx.xxx:8080/#/login
```
### 项目辅助脚本
在前面的项目打包和项目部署中都是采用手动命令来部署。
这里可以写一些脚本简化:
* util/packet.sh
在开发服务器运行可以自动项目打包
* util/lazy.sh
在开发服务器运行可以自动项目打包、项目上传远程服务器、自动登录系统执行项目部署脚本。
注意:
> 1. 开发者需要在util/lazy.sh中设置相应的远程服务器登录账号和密钥文件路径。
> 2. 开发者需要在bin/reset.sh设置远程服务器的MySQL的root登录账户。
* bin/deploy.sh
在远程服务器运行可以自动部署服务
* bin/reset.sh
在远程服务器运行可以自动项目导入数据、删除本地上传图片、再执行bin/deploy.sh部署服务。
注意:
> 开发者需要在bin/reset.sh设置远程服务器的MySQL的root登录账户。
总结当开发者设置好配置信息以后可以在本地运行lazy.sh脚本自动一键部署:
```bash
cd litemall
./deploy/util/lazy.sh
```
不过由于需要设置的信息会包含敏感安全信息强烈建议开发者参考这里的deploy文件夹
然后实现自己的deploy文件夹妥善处置外部配置文件和脚本中的敏感安全信息!!!