1. 安装docker 请参考阿里网站 安装Docker并使用(Linux)
  2. 接下来请参考 Docker部署ruoyi前后端分离项目
  3. 后端项目补充说明:后端项目部署成功,包括mysql和redis
    前端项目部署补充说明:(稍微修改了下)
    创建两个文件夹存放前端项目和nginx配置文件
mkdir -p /data/nginx/{conf,html}
进入/data/nginx/conf目录,配置nginx配置文件Default.conf
cd /data/nginx/conf

可以用vim打开这个文件

vim Default.conf

Default.conf的内容:

server {
    listen       80;
    server_name  localhost;

    
    location / {
        root   /usr/share/nginx/html/dist;
        index  index.html index.htm;
	try_files $uri $uri/ /index.html;
    }

    location /prod-api/{
    	proxy_set_header Host $proxy_host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_pass http://192.168.0.107:8081/;#192.168.0.107是ubuntu宿主机ip,8081是后端端口
    }
    #error_page  404              /404.html;
    
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

运行

docker run -itd --name zking-nginx --network net-ry -p 80:80 \
-v /data/nginx/conf/Default.conf:/etc/nginx/nginx.d/Default.conf \
-v /data/nginx/html:/usr/share/nginx/html \
--privileged=true --restart=always \
nginx
Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐