Skip to content

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

你可以使用 Kinsta 应用托管 在其云托管上托管 Astro 网站。

¥You can use Kinsta Application Hosting to host an Astro site on their cloud hosting.

¥Configuring your Astro project

¥Static hosting

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

¥To host your project on Kinsta Application Hosting, you need to:

  • package.json 中包含 name 字段。(这可以是任何内容,并且不会影响你的部署。)

  • package.json 中包含 build 脚本。(你的 Astro 项目应该已经包含这个。)

  • 安装 serve 包并将 start 脚本设置为 serve dist/

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

¥Here are the necessary lines in your package.json file:

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 应用托管上托管你的项目,你需要:

¥To host your project on Kinsta Application Hosting, you need to:

  • package.json 中包含 name 字段。(这可以是任何内容,并且不会影响你的部署。)

  • package.json 中包含 build 脚本。(你的 Astro 项目应该已经包含这个。)

  • 安装 @astrojs/node 包并将 start 脚本设置为 node ./dist/server/entry.mjs

  • astro.config.mjs 设置为使用 @astrojs/node 并使用 host: true

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

¥Here are the necessary lines in your package.json file:

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 文件中的必要行:

¥Here are the necessary lines in your astro.config.mjs file:

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
}
});

¥How to deploy

连接项目的 GitHub 存储库后,你可以在 MyKinsta 管理面板中触发手动部署到 Kinsta 应用托管。你还可以在管理面板中设置自动部署。

¥Once your project’s GitHub repository is connected, you can trigger manual deploys to Kinsta Application Hosting in the MyKinsta Admin Panel. You can also set up automatic deployments in your admin panel.

¥Configuring a new Kinsta application

  1. Go to the My Kinsta admin panel.

  2. Go to the Applications tab.

  3. Connect your GitHub repository.

  4. Press the Add service > Application button.

  5. Follow the wizard steps.

  6. Your application is deployed.

More Deployment Guides

Astro 中文网 - 粤ICP备13048890号