migrate-to-hosting

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Migrate to hosting

迁移到虚拟主机

The old host keeps serving the site until the copy on Hostinger is proven to work. DNS moves last.
在 Hostinger 上的副本被证明能够正常工作之前,旧主机会继续为该站点提供服务。最后再切换 DNS。

Calling the operations

调用操作

  • Read the
    inputSchema
    that
    search
    returns before the first call of each operation. If a name below is rejected as unknown,
    search
    for what the step does (e.g. "import wordpress").
  • Batch reads with
    multi-execute
    . Batches chain operations from one server only — the Hostinger Connector runs
    hosting
    ,
    wordpress
    ,
    agency-hosting
    ,
    domains
    and
    dns
    as separate servers.
  • Imports and deploys overwrite the target website's contents; confirm the target before each one.
  • 在首次调用每个操作之前,读取
    search
    返回的
    inputSchema
    。如果下面的某个名称被判定为未知,请通过
    search
    查询该步骤的作用(例如 "import wordpress")。
  • 使用
    multi-execute
    批量读取。批次只能串联同一服务器上的操作——Hostinger Connector 将
    hosting
    、
    wordpress
    、
    agency-hosting
    、
    domains
    和
    dns
    作为独立服务器运行。
  • 导入和部署会覆盖目标网站的内容;每次执行前都要确认目标。

1. What is being moved

1. 要迁移的内容

Establish, asking only for what cannot be inferred:
  • Site type: WordPress, static, PHP (with or without MySQL), or Node.js.
  • The export:
    • WordPress — an archive of the whole WordPress root (including
      wp-content
      and
      wp-config.php
      ) and a
      .sql
      dump.
    • PHP — a files archive, plus a
      .sql
      dump when the app has a database.
    • Static — the files. Node.js — the source or its Git repository.
    • Without one, the user exports it from the old host's panel, or over SSH:
      tar -czf site.tar.gz -C /path/to/site .
      and
      mysqldump --single-transaction -u USER -p DBNAME > db.sql
      .
  • The exact home URL (
    https
    , with or without
    www
    ) — WordPress keeps it in the database, so the new site must answer on the same one.
  • Current DNS, to preserve what already works:
bash
dig +short NS DOMAIN; dig +short A DOMAIN; dig +short MX DOMAIN; dig +short TXT DOMAIN
  • Cron jobs on the old host — they do not move with the files.
先确定以下信息,仅询问无法推断的部分:
  • 站点类型: WordPress、静态站点、PHP(有无 MySQL 均可)或 Node.js。
  • 导出内容:
    • WordPress——整个 WordPress 根目录的归档(包含
      wp-content
      和
      wp-config.php
      )以及一个
      .sql
      dump。
    • PHP——文件归档;如果应用包含数据库,还需要一个
      .sql
      dump。
    • 静态站点——文件。Node.js——源代码或其 Git 仓库。
    • 如果没有导出文件,用户需从旧主机的控制面板导出,或通过 SSH 执行:
      tar -czf site.tar.gz -C /path/to/site .
      和
      mysqldump --single-transaction -u USER -p DBNAME > db.sql
      。
  • 准确的主页 URL(
    https
    ,带或不带
    www
    )——WordPress 会将其保存在数据库中,因此新站点必须响应同一个 URL。
  • 当前 DNS 配置,以保留已经可用的设置:
bash
dig +short NS DOMAIN; dig +short A DOMAIN; dig +short MX DOMAIN; dig +short TXT DOMAIN
  • 旧主机上的 Cron jobs——不会随文件一起迁移。

2. Create the website on the real domain

2. 在正式域名上创建网站

Create the Hostinger website on the domain being migrated, not on a free subdomain: step 4 tests it by pointing only this machine at Hostinger, so nothing changes for visitors yet.
  • Shared and Cloud:
    hosting_domains_verify-ownership
    first. When
    is_accessible
    is false, the user adds the returned
    TXT
    record at their current DNS provider, next to the existing ones, and verification is repeated. Then
    hosting_websites_create
    with
    domain
    and
    order_id
    (from
    hosting_orders_list
    ), and poll
    hosting_websites_list-setups
    with
    domain
    every 10–15 s until
    status: completed
    .
  • Agency:
    agency-hosting_website-setups_create
    with the
    domain
    ,
    flavor: "php-fpm"
    , a
    settings.php.version
    matching the old host (options in
    agency-hosting_php_list-versions-for-order
    ) and
    datacenter_code
    from
    agency-hosting_datacenters_list
    . Poll
    agency-hosting_website-setups_status
    until
    completed
    for the
    website_uid
    .
在要迁移的域名下创建 Hostinger 网站,而不是使用免费子域名:第 4 步只会让当前机器指向 Hostinger 来进行测试,因此此时访客看到的内容不会发生变化。
  • Shared 和 Cloud:首先执行
    hosting_domains_verify-ownership
    。当
    is_accessible
    为 false 时,用户需在当前 DNS 服务商处添加返回的
    TXT
    记录,并将其放在现有记录旁边,然后再次执行验证。接着使用
    domain
    和
    order_id
    (来自
    hosting_orders_list
    )调用
    hosting_websites_create
    ,并每 10–15 秒使用
    domain
    轮询
    hosting_websites_list-setups
    ,直至
    status: completed
    。
  • Agency:使用
    domain
    、
    flavor: "php-fpm"
    、与旧主机匹配的
    settings.php.version
    (选项来自
    agency-hosting_php_list-versions-for-order
    )以及来自
    agency-hosting_datacenters_list
    的
    datacenter_code
    调用
    agency-hosting_website-setups_create
    。随后针对
    website_uid
    轮询
    agency-hosting_website-setups_status
    ,直至
    completed
    。

3. Import

3. 导入

hosting_deploy
with
path
and
agency-hosting_deploy-php-application
read files from this machine, so only the local
hostinger-api-mcp
server has them; the hosted server's
hosting_deploy
deploys Git repositories only. On the hosted server (
mcp.hostinger.com
), upload the files first as described in the
deploy-to-hosting
skill ("Without the local deploy operations") and use the operation named in brackets below.
WordPress, Shared and Cloud:
hosting_deploy
with
domain
,
path
(the site directory or its archive),
databaseDump
and
type: "wordpress-site"
uploads both, extracts the files and imports the database; large sites take several minutes. Always pass
type
: left to detection, a directory without
wp-config.php
or
wp-content
at its top level is taken for a plain site and the dump is not imported. [Upload
site.zip
and
dump.sql
, then
wordpress_installations_import-website
with
archive_path
and
sql_path
.] Then
wordpress_installations_detect
with
username
and poll
wordpress_installations_list
with
domain
until the install appears with
is_valid: true
.
Static, or PHP without a database:
hosting_deploy
with
domain
and
path
[upload, then
hosting_websites_deploy-static-site-archive
]; Agency:
agency-hosting_deploy-php-application
[upload to
.h5g/
, then
agency-hosting_files_import-website-from-archive
].
PHP with a database, Shared and Cloud:
  1. hosting_databases_create
    with a strong generated password; read the full name, user and
    host
    back from
    hosting_databases_list
    .
  2. Import the dump from this machine: allow only its public IP (
    curl -s https://api.ipify.org
    ) with
    hosting_databases_create-remote-connection
    , run
    mysql -h HOST -u USER -p NAME < db.sql
    , then remove the rule with
    hosting_databases_delete-remote-connection
    . Without a MySQL client, use
    hosting_databases_phpmyadmin-link
    and import there.
  3. Put the new name, user and password into the app's config file, with host
    localhost
    , before archiving; then deploy as above. Never ship the
    srvNNNN.hstgr.io
    host inside the app.
Node.js: deploy with the
deploy-to-hosting
skill. When a dump must be imported, create the database with
hosting_databases_create
rather than
hosting_databases_setup-website
— the latter never reveals the password needed for the import — and pass the credentials through environment variables.
Agency: files with
agency-hosting_deploy-php-application
[or upload plus
agency-hosting_files_import-website-from-archive
]; the database with
agency-hosting_databases_create-website
, imported through phpMyAdmin in hPanel (no import operation exists). For WordPress, set the new credentials in
wp-config.php
before archiving.
带
path
参数的
hosting_deploy
和
agency-hosting_deploy-php-application
会从当前机器读取文件,因此这些文件只存在于本地
hostinger-api-mcp
服务器上;托管服务器上的
hosting_deploy
只能部署 Git 仓库。在托管服务器(
mcp.hostinger.com
)上,应先按照
deploy-to-hosting
skill 中(“Without the local deploy operations”)的说明上传文件,然后使用下文方括号中注明的操作。
WordPress,Shared 和 Cloud: 使用
domain
、
path
(站点目录或其归档)、
databaseDump
和
type: "wordpress-site"
调用
hosting_deploy
,即可上传这两项、解压文件并导入数据库;大型站点可能需要数分钟。务必始终传入
type
:若交给自动检测,顶层不含
wp-config.php
或
wp-content
的目录会被视为普通站点,且不会导入 dump。[上传
site.zip
和
dump.sql
,然后使用
archive_path
和
sql_path
调用
wordpress_installations_import-website
。] 接着使用
username
调用
wordpress_installations_detect
,并使用
domain
轮询
wordpress_installations_list
,直到安装记录出现且
is_valid: true
。
静态站点,或无数据库的 PHP: 使用
domain
和
path
调用
hosting_deploy
[上传后调用
hosting_websites_deploy-static-site-archive
];Agency:使用
agency-hosting_deploy-php-application
[上传至
.h5g/
后调用
agency-hosting_files_import-website-from-archive
]。
带数据库的 PHP,Shared 和 Cloud:
  1. 使用
    hosting_databases_create
    创建数据库并设置强生成密码;从
    hosting_databases_list
    中读取数据库完整名称、用户和
    host
    。
  2. 从当前机器导入 dump:使用
    hosting_databases_create-remote-connection
    仅允许当前机器的公共 IP(
    curl -s https://api.ipify.org
    )访问,运行
    mysql -h HOST -u USER -p NAME < db.sql
    ,然后使用
    hosting_databases_delete-remote-connection
    删除该规则。如果没有 MySQL 客户端,则使用
    hosting_databases_phpmyadmin-link
    并在其中导入。
  3. 在归档前,将新的数据库名称、用户和密码写入应用配置文件,并将
    host
    设置为
    localhost
    ;然后按上述方式部署。切勿在应用中写入
    srvNNNN.hstgr.io
    主机地址。
Node.js: 使用
deploy-to-hosting
skill 部署。如果必须导入 dump,请使用
hosting_databases_create
创建数据库,而不要使用
hosting_databases_setup-website
——后者不会显示导入所需的密码——并通过环境变量传递凭据。
Agency: 文件使用
agency-hosting_deploy-php-application
[或先上传,再调用
agency-hosting_files_import-website-from-archive
];数据库使用
agency-hosting_databases_create-website
,并通过 hPanel 中的 phpMyAdmin 导入(不存在导入操作)。对于 WordPress,请在归档前将新凭据写入
wp-config.php
。

4. Test before DNS moves

4. 在切换 DNS 前进行测试

Find the server address:
details.ipv4
for Agency; for Shared and Cloud, the
A
record for
@
in the Hostinger zone (
dns_records_list
on the domain) or the IP hPanel shows for the website. Then point only this machine at it:
bash
curl -sSk --resolve DOMAIN:443:IP -o /dev/null -w "%{http_code}\n" https://DOMAIN/
curl -sSk --resolve DOMAIN:443:IP https://DOMAIN/ | grep -o "TEXT FROM THE LIVE SITE"
curl -sSk --resolve DOMAIN:443:IP -o /dev/null -w "%{http_code}\n" https://DOMAIN/wp-login.php
-k
is expected here: the certificate for the domain can only be issued after DNS moves. Check the home page, an inner page and, for WordPress, the login page. For a look in the browser, the user adds
IP DOMAIN www.DOMAIN
to their hosts file and removes it afterwards. Fix anything broken now, while visitors still see the old site.
查找服务器地址:Agency 使用
details.ipv4
;Shared 和 Cloud 使用 Hostinger DNS 区域中
@
的
A
记录(在域名上执行
dns_records_list
),或使用 hPanel 显示的网站 IP。然后只让当前机器指向该地址:
bash
curl -sSk --resolve DOMAIN:443:IP -o /dev/null -w "%{http_code}\n" https://DOMAIN/
curl -sSk --resolve DOMAIN:443:IP https://DOMAIN/ | grep -o "TEXT FROM THE LIVE SITE"
curl -sSk --resolve DOMAIN:443:IP -o /dev/null -w "%{http_code}\n" https://DOMAIN/wp-login.php
这里使用
-k
是预期现象:域名的证书只能在 DNS 切换后签发。检查主页、内部页面;对于 WordPress,还要检查登录页面。若想在浏览器中查看,用户可在 hosts 文件中添加
IP DOMAIN www.DOMAIN
,并在完成后将其删除。现在修复所有问题,此时访客看到的仍是旧站点。

5. Switch DNS and SSL

5. 切换 DNS 和 SSL

Follow the
connect-domain
skill from its DNS step: keep every
MX
and
TXT
record from step 1, then install SSL once the domain resolves to Hostinger. When the user controls the old DNS, lowering the TTL of the
A
records to 300 a day ahead shortens the switch.
从 DNS 步骤开始遵循
connect-domain
skill:保留第 1 步中的每一条
MX
和
TXT
记录,然后在域名解析到 Hostinger 后安装 SSL。如果用户控制旧 DNS,可提前一天将
A
记录的 TTL 降至 300,以缩短切换时间。

6. After the switch

6. 切换后

  • Verify without
    --resolve
    :
    curl -sSI https://DOMAIN/
    shows
    platform: hostinger
    .
  • Recreate the old host's cron jobs with
    hosting_cron-jobs_create
    (Agency:
    agency-hosting_cron-jobs_create-website
    ).
  • Keep the old hosting running for a few days — some resolvers still cache the old address, and email hosted there must be moved separately.
  • 不使用
    --resolve
    进行验证:
    curl -sSI https://DOMAIN/
    应显示
    platform: hostinger
    。
  • 使用
    hosting_cron-jobs_create
    重新创建旧主机上的 Cron jobs(Agency:
    agency-hosting_cron-jobs_create-website
    )。
  • 让旧托管服务继续运行几天——部分 DNS 解析器仍会缓存旧地址,且旧主机上的电子邮件需要单独迁移。