阿里云搭建springcloud+vue项目(二)

1.进入nacos目录,启动nacos

sh startup.sh -m standalone

关闭nacos

sh shutdown.sh

2.启动springboot 微服务项目

https://blog.csdn.net/qq_42169450/article/details/122688940

到微服务所在的目录下,执行

nohup java -jar xxx.jar &

nohup 即 no hang up 不挂断 ,关闭SSH客户端连接,程序不会中止运行

缺省情况下该作业的所有输出被重定向到nohup.out的文件中

默认设置的springboot微服务占用内存较大,需要优化

nohup java -Xms64m -Xmx128m  -jar xxxx.jar &

 

3.打包vue项目

npm run build

生成dist目录,上传dist目录至服务器

4.配置域名、二级域名(没有需要则不做)

域名控制台-域名列表-解析-添加记录

5.安装nginx并进行配置,配置好后需要重启nginx

server
    {
        listen 7010;
        server_name 172.xx.xx.92;
        
        location / {
            root /www/wwwroot/Mooxxxxxient/;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
        location /api/  {
            proxy_pass http://121.40.xx.xx:8889/;

        #代理请求头相关
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-Ip $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        }
        access_log  /www/wwwlogs/access.log;
    }

 

 

 

如果起两个端口不同的前端项目 ,只需要复制一次server{}并且修改里面的内容。

然后浏览器输入http://ip:7020/index.html就可以了

posted @ 2022-10-13 23:30  盐排骨  阅读(223)  评论(0)    收藏  举报