将你的 Astro 站点部署到 Kinsta 应用托管
你可以使用 Kinsta 应用托管 在其云托管上托管 Astro 网站。
¥You can use Kinsta Application Hosting to host an Astro site on their cloud hosting.
配置你的 Astro 项目
Section titled “配置你的 Astro 项目”¥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:
{ "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:
{ "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:
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.
配置新的 Kinsta 应用
Section titled “配置新的 Kinsta 应用”¥Configuring a new Kinsta application
-
Go to the My Kinsta admin panel.
-
Go to the Applications tab.
-
Connect your GitHub repository.
-
Press the Add service > Application button.
-
Follow the wizard steps.
-
Your application is deployed.