一. 前端项目打包成dist文件
npm run build
二. 获取nginx 镜像
1. docket 要在linux系统下安装,或是linux模拟器下
2. 下载nginx
3. 在nginx终端执行命令 docker pull nginx 即可获取到nginx镜像。
docker image ls 该命令可以查看nginx的镜像信息
三. 创建 nginx config配置文件
在项目根目录下创建nginx
文件夹,该文件夹下新建文件default.conf
server {
listen 80; // 部署服务器对应的端口(需要修改)
server_name localhost; // 部署服务器对应的路径(需要修改)
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
error_log /var/log/nginx/error.log error;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the stati