environment-management
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEnvironment Management with Acquia CLI
使用Acquia CLI进行环境管理
Use when:
- Creating or deleting Continuous Delivery Environments (CDEs)
- Making one environment identical to another (mirroring)
- Copying cron tasks between environments
- Installing SSL certificates
- Listing or inspecting environments
- Deploying code to an environment
适用场景:
- 创建或删除持续交付环境(CDE)
- 使一个环境与另一个环境完全一致(镜像)
- 在环境之间复制定时任务(cron)
- 安装SSL证书
- 列出或查看环境信息
- 向环境部署代码
List Environments
列出环境
bash
acli api:applications:environment-listShows all environments for an application (prod, staging, dev, and any CDEs).
bash
acli api:applications:environment-list显示某个应用的所有环境(生产环境、预发布环境、开发环境以及所有CDE)。
Get Environment Details
获取环境详情
bash
acli env:infoShows PHP version, database, last deployment, URLs, and status for the selected environment.
bash
acli env:info显示所选环境的PHP版本、数据库信息、上次部署记录、URL以及状态。
Create a Continuous Delivery Environment (CDE)
创建持续交付环境(CDE)
CDEs are on-demand environments — useful for testing feature branches before merging.
bash
acli env:create "My Feature Branch" feature/my-branchArguments:
- (required) — Human-readable name for the new environment
label - (optional) — The git branch to deploy; prompts if omitted
branch
bash
undefinedCDE是按需创建的环境——非常适合在合并代码前测试功能分支。
bash
acli env:create "My Feature Branch" feature/my-branch参数:
- (必填)——新环境的可读名称
label - (可选)——要部署的Git分支;若省略则会提示输入
branch
bash
undefinedInteractive (prompts for branch)
交互式(提示输入分支)
acli env:create "QA Review"
acli env:create "QA Review"
Non-interactive
非交互式
acli env:create "Sprint 42 Demo" release/sprint-42
---acli env:create "Sprint 42 Demo" release/sprint-42
---Delete a CDE
删除CDE
bash
acli env:deletePrompts you to select the environment to delete. Only CDEs can be deleted; production and standard environments cannot.
bash
acli env:delete提示选择要删除的环境。仅CDE可被删除;生产环境和标准环境无法删除。
Deploy Code to an Environment
向环境部署代码
bash
acli api:environments:code-switch <environmentId> <branch>Example:
bash
acli api:environments:code-switch 112927-9454a2b1-cce0-475e-ae5f-5374dbca9b0a masterReturns a notification UUID you can track with .
acli app:task-wait <uuid>bash
acli api:environments:code-switch <environmentId> <branch>示例:
bash
acli api:environments:code-switch 112927-9454a2b1-cce0-475e-ae5f-5374dbca9b0a master返回一个通知UUID,可通过跟踪进度。
acli app:task-wait <uuid>Mirror an Environment
镜像环境
Makes a destination environment identical to a source — copies code, database, files, and config.
bash
acli env:mirror <source-environment> <destination-environment>Use environment aliases in the format :
app-name.envbash
acli env:mirror myapp.prod myapp.stagingSkip specific components:
bash
acli env:mirror myapp.prod myapp.staging \
--no-code \ # -c: skip code
--no-databases \ # -d: skip databases
--no-files \ # -f: skip files
--no-config # -p: skip configurationWarning: This overwrites the destination. All existing data in the destination environment is replaced.
使目标环境与源环境完全一致——复制代码、数据库、文件和配置。
bash
acli env:mirror <source-environment> <destination-environment>使用格式为的环境别名:
app-name.envbash
acli env:mirror myapp.prod myapp.staging跳过特定组件:
bash
acli env:mirror myapp.prod myapp.staging \
--no-code \ # -c: 跳过代码
--no-databases \ # -d: 跳过数据库
--no-files \ # -f: 跳过文件
--no-config # -p: 跳过配置警告: 此操作会覆盖目标环境。目标环境中的所有现有数据将被替换。
Copy Cron Tasks Between Environments
在环境之间复制定时任务(Cron)
Copy all cron tasks from one environment to another:
bash
acli env:cron-copy <source_env> <dest_env>Example:
bash
acli env:cron-copy myapp.prod myapp.stagingUseful after mirroring an environment to ensure scheduled tasks match.
将所有定时任务从一个环境复制到另一个环境:
bash
acli env:cron-copy <source_env> <dest_env>示例:
bash
acli env:cron-copy myapp.prod myapp.staging在镜像环境后使用此命令非常有用,可确保定时任务保持一致。
Install an SSL Certificate
安装SSL证书
bash
acli env:certificate-create <certificate> <private-key>Options:
bash
acli env:certificate-create \
/path/to/cert.pem \
/path/to/private-key.pem \
--label="My SSL Cert" \
--ca-certificates=/path/to/ca-bundle.pem \
--legacy # Use legacy SSL (non-SNI)To install from an existing CSR:
bash
acli env:certificate-create cert.pem key.pem --csr-id=<csr-uuid>bash
acli env:certificate-create <certificate> <private-key>选项:
bash
acli env:certificate-create \
/path/to/cert.pem \
/path/to/private-key.pem \
--label="My SSL Cert" \
--ca-certificates=/path/to/ca-bundle.pem \
--legacy # 使用旧版SSL(非SNI)从现有CSR安装:
bash
acli env:certificate-create cert.pem key.pem --csr-id=<csr-uuid>Typical Workflows
典型工作流程
Set up a CDE for a feature branch
为功能分支设置CDE
bash
undefinedbash
undefinedCreate the environment
创建环境
acli env:create "Feature: New Checkout" feature/new-checkout
acli env:create "Feature: New Checkout" feature/new-checkout
Mirror prod data to it
将生产环境数据镜像到该环境
acli env:mirror myapp.prod myapp.<new-cde-id>
undefinedacli env:mirror myapp.prod myapp.<new-cde-id>
undefinedRefresh staging from production
从生产环境刷新预发布环境
bash
acli env:mirror myapp.prod myapp.stagingbash
acli env:mirror myapp.prod myapp.stagingPromote staging to prod
将预发布环境代码推广到生产环境
bash
acli api:environments:code-switch <prod-env-id> mainbash
acli api:environments:code-switch <prod-env-id> mainBest Practices
最佳实践
- Mirror before testing — Always sync a CDE from prod or staging before QA.
- Clean up CDEs — Delete CDEs when done; they consume resources.
- Test deploys in staging first — Always deploy to staging before production.
- Copy crons after mirror — Run after mirroring to keep scheduled tasks in sync.
env:cron-copy
- 测试前先镜像 —— 在QA测试前,务必将CDE与生产环境或预发布环境同步。
- 清理CDE —— 完成测试后删除CDE;它们会消耗资源。
- 先在预发布环境测试部署 —— 部署到生产环境前,务必先部署到预发布环境。
- 镜像后复制定时任务 —— 镜像完成后运行,确保定时任务保持同步。
env:cron-copy
Troubleshooting
故障排查
"Environment not found"
"环境未找到"
Check available environments:
bash
acli api:applications:environment-list检查可用环境:
bash
acli api:applications:environment-listMirror fails midway
镜像中途失败
Check logs and retry. Use or to skip the component that failed:
--no-databases--no-filesbash
acli env:mirror myapp.prod myapp.staging --no-files查看日志并重试。使用或跳过失败的组件:
--no-databases--no-filesbash
acli env:mirror myapp.prod myapp.staging --no-filesRelated Topics
相关主题
- Pull & Push — Sync local and Cloud environments
- Application Management — Find application UUIDs
- Remote Access — SSH and Drush on environments
- 拉取与推送 —— 同步本地和Cloud环境
- 应用管理 —— 查找应用UUID
- 远程访问 —— 在环境上使用SSH和Drush