
Summary
Key points of this document
- First, let's define what "IaC-like" operations mean.
- The scope of Git management is limited to "code."
- Manage state declaratively with WP-CLI.
Overview
In a cloud-native environment, IaC and CI/CD are standard equipment. However, the web assets of real-world SMEs run on WordPress on rental servers. We will explain how far we can build reproducible and safe operations, breaking away from manual FTP uploads, within the constraints of not having root privileges.
First, let's define what "IaC-like" operations mean.
The goal of this article is not IaC itself, but to reproduce the three values of IaC in a rental server environment. Reproducibility: Executing the same steps leads to the same state. Visibility: What changed and when is recorded in history. Reversibility: If a problem occurs, it can be reverted to a previous state. If these three are met, it qualifies as IaC-like operations, even without root privileges.
The scope of Git management is limited to "code."
The starting point is to classify WordPress components into "code," "state," and "content." What is managed by Git includes custom themes, custom plugins, and configuration files. What is not managed by Git includes the WordPress core, third-party plugins, media, and the database.
The core and plugins should be version-specified rather than version-controlled, and media and DB are not code in the first place. With this classification, the repository becomes a clean state of "only what we wrote," and the context for entrusting changes to an AI agent becomes clear.
Manage state declaratively with WP-CLI.
Place plugins.txt (a list of plugin names and versions) in the repository and run a script to apply it during deployment. This ensures that the production plugin configuration matches the repository's description, allowing detection of configuration drift such as "someone installed a plugin from the admin screen without us knowing."
While complete convergence like Terraform is not possible, even just "detecting and warning about discrepancies between declaration and reality" significantly improves operational quality. Difference detection is run daily via cron, and notifications are sent if drift is found.
rsync is used with a three-piece set: dry run, exclusion list, and pre-deployment snapshot.
First, we always perform a dry run first, confirm the differences to be transferred, and then proceed with the actual deployment in two stages. Even when entrusting deployment to an AI agent, we insert a gate where a human confirms the dry run results.
Second, the handling of the --delete option. When combined with incorrect exclusion settings, it has the power to wipe out production uploads. We fix the exclusion list in a script and prohibit manual rsync execution.
Third, a snapshot just before deployment. Before executing rsync, the theme directory is tarred on the server and saved with a timestamp. By having our own restore point "just before deployment," rollbacks can be completed in minutes.
Build a pseudo CI/CD with GitHub Actions.
For pull requests: PHP syntax check and coding standards. For main branch merges: automatic deployment to a staging environment (built on a subdomain) and execution of smoke tests with Playwright. Production deployment is not automated; it requires a manual trigger with human approval. The execution content is the same script as for staging.
A crucial principle is to make the script executed by CI identical to the script executed by humans locally. Consolidate into a single script named deploy.sh, and make CI a thin wrapper that just calls it. "Works in CI but not locally" robs you of emergency response capability.
Even acknowledging the limitations, it's still worth doing.
DB migrations are outside the scope of automation. Staging and production DB contents will diverge. Server settings are managed via the admin panel and cannot be codified.
Nevertheless, there are clear values: eliminating reliance on individuals, establishing a collaboration foundation with AI agents, and preventing accidents. The triple gates of dry run, snapshot, and staging verification structurally prevent the most frequent accident: "directly tampering with and breaking production."
The idea that modern operations are impossible because it's a rental server is a misconception. The understanding of translating IaC principles within constraints will definitely be valuable when the day comes to migrate to the cloud.
- The staging DB is synchronized with regular copies of the production DB, with personal information masked, and email sending is disabled.
- Plugin updates: minor versions are automatic, major versions require updating
plugins.txtand applying after staging verification. - For multiple sites, standardize
deploy.sh, externalize site-specific settings, and scale horizontally. - It is reasonable to require the following three points from contractors: "Git history," "staging verification," and "prohibition of direct production editing."


