Nginx前后端服务器部署

Nginx作为正反向代理的中转站,是连接前后端网络服务的媒介

Nginx前后端服务器部署_第1张图片

Nginx下载:http://nginx.org/download/icon-default.png?t=N6B9http://nginx.org/download/

一、上传到服务器固定路径下并解压

        上传到/opt/software/nginx-1.19.0.tar.gz

        cd /opt/software/

        tar -zxvf  nginx-1.19.0.tar.gz

        mv nginx-1.19.0.tar.gz nginx

        cd nginx

        ./configure

        make

        make install

二、将前端打成的dist包放到/opt/front/目录下,将后端的打成的jar包也放到/opt/backend/下

三、启动后端jar包,nohup java -jar /opt/backend/xxxx.jar &

四、配置nginx

        cd /opt/software/nginx/conf/

        vim nginx.confNginx前后端服务器部署_第2张图片

                找到http标签下的server 

                listen:访问前端的界面端口

                server:部署的服务器的ip

                location是前端dist包路径,

                      root是用户(一般都是root,可以根据自己需求改,但改完会报路径下没有xxx用户)

                      index是前端索引入户标签,不用管

                location /api/是后端请求地址

                       只需要改最下面一行的ip:port/

五、启动nginx

        cd /opt/software/nginx/sbin

        ./nginx

六、查看nginx是否启动

        ps -ef | grep nginx

命令行:

        ./nginx -s reload                重启nginx

 

你可能感兴趣的:(nginx)