linux配置nuxt项目

安装node: https://blog.csdn.net/jiangyu1013/article/details/80980765

安装pm2:npm install pm2 -g

 npm install报错,解决:npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass

部署nuxt项目到服务器

1.本地项目执行命令
npm run build
2.服务器新建一个文件夹备份上次的文件

3.将文件:static .nuxt nuxt.config.js package.js文件放入linux中,路径:/var/www/ssr-website/
4.命令窗口进入项目路径,执行命令 pm2 ls查看pm2管理的项目,
其中npm是对应的 sourcingbuy未登录的首页项目(项目名称改为website id是8)
5.关闭npm 命令
pm2 stop 0
//0是npm对应的id
5.1 如果有新引入的模块,需要npm install
6.启动项目
npm run start
7.开启进程守护
pm2 start npm --name "website" -- run start

8.删除旧的进程:根据id
pm2 delete id //id换成对应的数字

9.移动文件(或文件夹)到另一个文件夹
mv test.js sitemap.xml -t ./20211116
从文件夹移出文件到上一级文件
mv sitemap.xml -t ../
10删除文件
rm -rf /file

 

11.配置sitemap.xml

nuxt.config.js.js文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
sitemap: {
    path: '/sitemap.xml', // sitemap path,不用改
    hostname: 'https://www.sourcinbox.com',
    gzip: true,
    cacheTime: 1000 * 60 * 60 * 24,
    generate: false,
    exclude: ['/404', '/401'],
    defaults: {
      changefreq: 'always',
      lastmod: new Date()
    },
    routes: async () => {
 
      // 从后台获取数据,拼接url生成更多的xml数据
      // const getUrl = 'https://******'
      // const { data } = await axios.get(getUrl)
      const routes = [
        {
          url: "/"//  这里的路径相对 hostname
          changefreq: "daily",
          lastmod: new Date(),
          priority: 1
        },
        {
          url: "/blog",
          changefreq: "daily",
          lastmod: new Date(),
          priority: 0.9
        },
        {
          url: "/partner",
          changefreq: "daily",
          lastmod: new Date(),
          priority: 0.9
        },
        {
          url: "/contact-us",
          changefreq: "daily",
          lastmod: new Date(),
          priority: 0.9
        },
        {
          url: "/blog/woocommerce-integration-with-sourcinbox",<br><br>changefreq: "daily",<em id="__mceDel"><em id="__mceDel">          lastmod: new Date(),
          priority: 0.9
 
        },
]
     
 
      return routes
    }
 
  },
</em></em>

  运行项目命令:npm run generate

 

 将项目dist目录下sitemmap.xml放到服务器

 

 

 

 配置nginx

 

 如果更改sitemap.xml文件,需要重启nginx

 

posted @   枫若  阅读(297)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示