跳转到内容

将你的 Astro 网站部署到 Kinsta 应用托管

你可以使用 Kinsta 应用托管 在他们的云托管上部署 Astro 网站。

要在 Kinsta 应用托管 上托管你的项目,你需要:

  • 在你的 package.json 中包含一个 name 字段。(这可以是任何东西,不会影响你的部署。)
  • 在你的 package.json 中包含一个 build 脚本。(你的 Astro 项目应该已经包含了这个。)
  • 安装 serve 包,并将 start 脚本设置为 serve dist/

以下是你的 package.json 文件中必要的几行:

package.json
{
"name": "anything", // This is required, but the value does not matter.
"scripts": {
"dev": "astro dev",
"start": "serve dist/",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^2.2.0",
"serve": "^14.0.1"
},
}

要在 Kinsta 应用托管 上托管你的项目,你需要:

  • 在你的 package.json 中包含一个 name 字段。(这可以是任何东西,不会影响你的部署。)
  • 在你的 package.json 中包含一个 build 脚本。(你的 Astro 项目应该已经包含了这个。)
  • 安装 @astrojs/node 包,并将 start 脚本设置为 node ./dist/server/entry.mjs
  • astro.config.mjs 设置为使用 @astrojs/node 并使用 host: true

以下是你的 package.json 文件中必要的几行:

package.json
{
"name": "anything", // This is required, but the value does not matter.
"scripts": {
"dev": "astro dev",
"start": "node ./dist/server/entry.mjs",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^2.2.0",
"@astrojs/node": "^5.1.1"
},
}

以下是你的 astro.config.mjs 文件中必要的几行:

astro.config.mjs
import { defineConfig } from 'astro/config';
import node from "@astrojs/node";
export default defineConfig({
output: 'server',
adapter: node({
mode: "standalone"
}),
server: {
host: true
}
});

一旦你的项目的 GitHub 仓库连接好了,你就可以在 MyKinsta 管理面板 中手动触发部署到 Kinsta 应用托管。你也可以在你的管理面板中设置自动部署。

  1. 前往 My Kinsta 管理面板。

  2. 前往 应用程序 选项卡。

  3. 连接你的 GitHub 仓库。

  4. 按下 添加服务 > 应用程序 按钮。

  5. 按照向导的步骤操作。

  6. 你的应用程序已部署。

更多部署指南

贡献 社区 赞助