Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Automate WordPress Installation on Ubuntu with Ansible (Idempotent, Secure Guide)

A complete guide to provisioning WordPress on Ubuntu with Ansible—from inventory and encrypted secrets through database creation, web-server templates, WP-CLI installation, secure permissions, validation, and rollback planning.
Length13 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes—Ansible can provision the complete WordPress stack on Ubuntu: web server, PHP, MySQL-compatible database, WordPress files, configuration, WP-CLI, and the initial administrator account. A reliable design keeps infrastructure tasks idempotent, stores credentials in Ansible Vault, gives WordPress a dedicated least-privilege database user, and validates that a second playbook run makes no unnecessary changes.

The workflow below follows Ubuntu’s documented Apache path while showing where Nginx, per-site users, PHP-FPM, or a managed database fit. Package names and software requirements change, so pin and test versions against the Ubuntu release you actually operate instead of treating the examples as a universal production baseline.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What Ansible installs—and what it does not

Ansible is the orchestration layer. It connects from a control node to one or more Ubuntu managed hosts and converges their state toward your playbook. WordPress still depends on a web server, PHP and its extensions, and a MySQL-compatible database. WP-CLI supplies a repeatable, non-interactive bootstrap for the WordPress tables and first administrator.

A practical single-host flow is:

  1. Define inventory, site variables, and encrypted secrets.
  2. Install and start Apache or Nginx, PHP, database packages, archive tools, and Python database bindings.
  3. Create a database and a localhost application user with only the grants WordPress needs.
  4. Download the upstream WordPress release, unpack it, and apply deliberate ownership and modes.
  5. Template the virtual host and wp-config.php, notifying a web-server reload handler only when a file changes.
  6. Install WP-CLI, then run wp config create and wp core install as the site user.
  7. Check services, ports, routing, PHP, database access, and WordPress convergence.

Choose an architecture before writing tasks

There is no single correct topology. Decide these boundaries first; changing them after deployment usually means moving files, credentials, and service ownership.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Decision Simpler starting point More isolated alternative Trade-off
Web server Apache with the Ubuntu tutorial’s PHP integration Nginx with PHP-FPM Apache is straightforward for a first role; Nginx and separate FPM pools can provide tighter per-site resource and process isolation.
Bootstrap WP-CLI commands Browser-based five-minute setup WP-CLI is repeatable and CI/CD-friendly; the browser flow is useful for manual recovery but is harder to make deterministic.
Filesystem One site owned by www-data Per-site Unix users and PHP-FPM pools Shared ownership is operationally simple. Per-site identities reduce the blast radius on a multi-site host.
Database Local MySQL-compatible server Managed database service Local placement minimizes latency and setup. A managed service can improve failover and backups but requires network controls, TLS, and secret rotation.

The Ubuntu tutorial used for this workflow lists Ubuntu Server 20.04 LTS as its prerequisite. Treat that as the tutorial’s tested context, not a promise that every current Ubuntu release has identical package names or defaults.

Version and prerequisite checks

Record the target Ubuntu release, WordPress version, PHP version, database engine, and web server in your role’s test matrix. The WP-CLI installation documentation, accessed in 2026, lists PHP 7.2.24 or later. The WP-CLI project documentation also lists WordPress 4.9 or later and PHP 7.2.24 or later. Current WordPress requirements may be newer, so check them at deployment time and select packages that satisfy both WordPress and WP-CLI.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Component Check before deployment Why it matters
Ubuntu Exact release and enabled repositories Package names, PHP streams, service defaults, and security-update policy vary by release.
PHP Version supported by the selected WordPress release and WP-CLI An old interpreter can block installation or leave the site unsupported.
Database MySQL-compatible engine, authentication method, and character-set defaults Ansible database modules need compatible drivers and credentials.
Network SSH from the control node, DNS for the domain, and outbound access for approved downloads Missing connectivity causes failures that look like package or application errors.
Privileges A sudo-capable Ansible account on the managed host Package, service, filesystem, and database setup require escalation.

Lay out the Ansible project and protect secrets

Keep host-independent defaults in a role and put environment-specific values in inventory or group variables. Never commit database passwords, the WordPress administrator password, salts, or private keys in plaintext.

wordpress-ansible/
├── inventory/production/hosts.yml
├── group_vars/wordpress/main.yml
├── group_vars/wordpress/vault.yml
├── roles/wordpress/{defaults,tasks,handlers,templates,files}/
└── site.yml

An inventory can separate the control node from the managed host:

all:
  children:
    wordpress:
      hosts:
        wp01:
          ansible_host: 203.0.113.20
          ansible_user: deploy

Put non-secret settings in group_vars/wordpress/main.yml:

wordpress_domain: example.invalid
wordpress_path: /var/www/example
wordpress_db_name: wordpress_example
wordpress_db_user: wordpress_example
wordpress_db_host: localhost
wordpress_download_url: https://operator-selected-release.example/wordpress.tar.gz
wp_cli_download_url: https://operator-selected-release.example/wp-cli.phar
wordpress_admin_user: siteadmin
wordpress_admin_email: [email protected]
wordpress_admin_url: https://example.invalid

The URLs above are variables deliberately supplied by the operator or release process; choose an approved, current upstream artifact and pin its checksum rather than silently tracking a moving download. Encrypt the sensitive companion file:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
wordpress_db_password: vault-managed-database-password
wordpress_admin_password: vault-managed-wordpress-password
wp_cli_sha512: vault-managed-checksum

Create it with ansible-vault create group_vars/wordpress/vault.yml, and use a vault password mechanism appropriate for your CI system. Restrict the vault file and any generated logs, because command arguments and task output can otherwise expose credentials.

Prepare Ubuntu with package and service tasks

Use the package module rather than shelling out to apt. Refresh metadata once per run, install the web and PHP stack, and include the Python database bindings required by the Ansible collection you select.

- name: Refresh package metadata
  ansible.builtin.apt:
    update_cache: true
    cache_valid_time: 3600

- name: Install web, PHP, database, and utility packages
  ansible.builtin.apt:
    name:
      - apache2
      - php
      - php-mysql
      - php-curl
      - php-gd
      - php-mbstring
      - php-xml
      - php-zip
      - mysql-server
      - mysql-client
      - python3-pymysql
      - ca-certificates
      - curl
      - tar
      - unzip
    state: present

- name: Enable and start services
  ansible.builtin.service:
    name: '{{ item }}'
    enabled: true
    state: started
  loop:
    - apache2
    - mysql

This is an example package set, not a production baseline. Confirm names and PHP extensions for the target Ubuntu release, and use Nginx plus PHP-FPM packages when that is your fleet standard. If you use Nginx, template a server block and manage the FPM service instead of enabling Apache modules.

Create a least-privilege WordPress database

Install the community.mysql collection on the control node if your role uses its modules. The managed host needs a Python MySQL driver. Connect locally through the Unix socket or an administrative account; do not configure WordPress to use the database server’s root login.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
- name: Create the application database
  community.mysql.mysql_db:
    name: '{{ wordpress_db_name }}'
    state: present
    encoding: utf8mb4
    collation: utf8mb4_unicode_ci
    login_unix_socket: /run/mysqld/mysqld.sock

- name: Create a localhost-only application user
  community.mysql.mysql_user:
    name: '{{ wordpress_db_user }}'
    password: '{{ wordpress_db_password }}'
    host: localhost
    priv: '{{ wordpress_db_name }}.*:ALL'
    state: present
    login_unix_socket: /run/mysqld/mysqld.sock
  no_log: true

Use the database engine’s supported character set and collation for your release; the values shown are common WordPress choices, not a guarantee for every server. Keep the user restricted to the application database and localhost unless a separate database host requires a narrowly scoped network identity. For a managed database, replace socket authentication with TLS-protected credentials and firewall rules that allow only the application host.

Download WordPress and set filesystem ownership deliberately

Ubuntu’s documented workflow downloads the upstream WordPress release rather than installing the distribution archive package. Pin a specific release URL and checksum in variables when you need reproducible builds. Download to a temporary location, unpack into a stable path, and avoid deleting an existing installation until you have a rollback plan.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
- name: Download the pinned WordPress archive
  ansible.builtin.get_url:
    url: '{{ wordpress_download_url }}'
    dest: /tmp/wordpress.tar.gz
    checksum: '{{ wordpress_archive_checksum }}
    mode: '0644'

- name: Unpack WordPress into a staging directory
  ansible.builtin.unarchive:
    src: /tmp/wordpress.tar.gz
    dest: /tmp
    remote_src: true
    creates: /tmp/wordpress/wp-settings.php

- name: Create the document root
  ansible.builtin.file:
    path: '{{ wordpress_path }}'
    state: directory
    owner: www-data
    group: www-data
    mode: '0755'

- name: Copy the application tree into place
  ansible.builtin.copy:
    src: /tmp/wordpress/
    dest: '{{ wordpress_path }}/'
    remote_src: true
    owner: www-data
    group: www-data
    directory_mode: '0755'

The exact deployment method can instead use a release directory and an atomic symlink switch. That makes rollback safer, but it requires explicit handling for uploads, writable directories, and database migrations. Do not recursively make every file writable by the web server on a shared host: Ubuntu’s tutorial warns that blanket www-data ownership can be insecure when multiple sites coexist.

Template the virtual host and WordPress configuration

Apache path

Template an Apache virtual host with the domain, document root, directory permissions, and a handler that reloads Apache only when the template changes. Enable the site and disable the default site if it would otherwise catch requests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<VirtualHost *:80>
    ServerName {{ wordpress_domain }}
    DocumentRoot {{ wordpress_path }}
    <Directory {{ wordpress_path }}>
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/{{ wordpress_domain }}-error.log
    CustomLog ${APACHE_LOG_DIR}/{{ wordpress_domain }}-access.log combined
</VirtualHost>
- name: Enable the WordPress virtual host
  ansible.builtin.command: a2ensite wordpress.conf
  args:
    creates: /etc/apache2/sites-enabled/wordpress.conf
  notify: Reload Apache

- name: Enable rewrite support
  community.general.apache2_module:
    name: rewrite
    state: present
  notify: Reload Apache

Add TLS, HTTP-to-HTTPS redirection, security headers, and a firewall policy before exposing the site publicly. The example deliberately shows HTTP-only plumbing so that certificate issuance and renewal can be designed for your environment rather than assumed.

Nginx and PHP-FPM path

For Nginx, template a server block that points root at the WordPress path, sends PHP requests to the selected FPM socket, and denies direct access to sensitive files. Manage the FPM pool as a separate service. A per-site pool can run under a per-site Unix account, separating uploads and PHP execution from other sites.

Render wp-config.php with restrictive modes

<?php
define( 'DB_NAME', '{{ wordpress_db_name }}' );
define( 'DB_USER', '{{ wordpress_db_user }}' );
define( 'DB_PASSWORD', '{{ wordpress_db_password }}' );
define( 'DB_HOST', '{{ wordpress_db_host }}' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'WP_DEBUG', false );
$table_prefix = 'wp_';
require_once ABSPATH . 'wp-settings.php';
- name: Write wp-config.php with limited permissions
  ansible.builtin.template:
    src: wp-config.php.j2
    dest: '{{ wordpress_path }}/wp-config.php'
    owner: www-data
    group: www-data
    mode: '0640'
  no_log: true

Keep salts and other secret constants in Vault or generate them through a controlled secret system. Ensure the web server can read the file while ordinary users cannot. If your ownership model uses a per-site account, substitute that account consistently rather than mixing identities.

Install WP-CLI reproducibly

WP-CLI’s recommended installation downloads wp-cli.phar, optionally verifies its signature, marks it executable, and places it on PATH. Use an Ansible download task with a pinned checksum, then a file task and a command task guarded by creates.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
- name: Download WP-CLI
  ansible.builtin.get_url:
    url: '{{ wp_cli_download_url }}'
    dest: /usr/local/src/wp-cli.phar
    checksum: 'sha512:{{ wp_cli_sha512 }}'
    mode: '0644'

- name: Install WP-CLI on PATH
  ansible.builtin.copy:
    src: /usr/local/src/wp-cli.phar
    dest: /usr/local/bin/wp
    remote_src: true
    owner: root
    group: root
    mode: '0755'

- name: Check the CLI binary
  ansible.builtin.command: /usr/local/bin/wp --info
  register: wp_cli_info
  changed_when: false

Signature verification is an additional control when you can obtain and pin the publisher’s signing key through a trusted channel. Do not replace checksum or signature verification with an unpinned “latest” download in a production pipeline.

Complete the five-minute install non-interactively

Run WordPress commands as the account that owns the site files. First create the configuration if it does not exist, then test whether WordPress is already installed. Only run the table-creation command when that test says it is not installed.

- name: Create WordPress configuration when absent
  ansible.builtin.command:
    cmd: >-
      /usr/local/bin/wp config create
      --path={{ wordpress_path }}
      --dbname={{ wordpress_db_name }}
      --dbuser={{ wordpress_db_user }}
      --dbpass={{ wordpress_db_password }}
      --dbhost={{ wordpress_db_host }}
      --skip-check
    creates: '{{ wordpress_path }}/wp-config.php'
  become_user: www-data
  no_log: true

- name: Check whether WordPress is installed
  ansible.builtin.command:
    cmd: /usr/local/bin/wp core is-installed --path={{ wordpress_path }}
  become_user: www-data
  register: wordpress_install_check
  changed_when: false
  failed_when: false

- name: Create WordPress tables and administrator
  ansible.builtin.command:
    cmd: >-
      /usr/local/bin/wp core install
      --path={{ wordpress_path }}
      --url={{ wordpress_admin_url }}
      --title={{ wordpress_title }}
      --admin_user={{ wordpress_admin_user }}
      --admin_password={{ wordpress_admin_password }}
      --admin_email={{ wordpress_admin_email }}
  become_user: www-data
  when: wordpress_install_check.rc != 0
  no_log: true

The official wp core install command reference states that this command creates the WordPress tables from the supplied values. Keep the administrator password in Vault and suppress task output. If WordPress is served from a subdirectory, set siteurl to that subdirectory URL after installation, while keeping the home URL appropriate for the public address.

Make the role idempotent

Idempotence means a second run reports no changes when the desired state has not changed. It is more than adding creates to commands.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Use package, service, file, template, get_url, and database modules for resources they understand.
  • Use command guards such as creates, check commands, or registered state tests for operations that have no native module.
  • Set changed_when: false on read-only checks, including version and health probes.
  • Attach handlers to templates and module changes so Apache or PHP-FPM reloads only after configuration changes.
  • Pin archive checksums and avoid downloading a moving “latest” file on every run.
  • Keep database grants explicit. A changed password should be an intentional Vault change, not an accidental task-side effect.
  • Separate one-time bootstrap from recurring maintenance such as plugin updates, backups, and log rotation.
handlers:
  - name: Reload Apache
    ansible.builtin.service:
      name: apache2
      state: reloaded

Run the playbook twice in a disposable environment and inspect the second result. Unexpected changes usually indicate a non-idempotent shell command, an unstable download, a template value that changes each run, or ownership and mode tasks fighting another process.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Validate the deployed site

Validation should test the path a user and an operator depend on, not merely whether packages are installed.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  1. Check that Apache or Nginx, PHP-FPM when used, and MySQL are enabled and active.
  2. Confirm the expected listening ports and firewall rules; do not expose the database port publicly unless a tightly controlled design requires it.
  3. Resolve the domain to the intended host and verify virtual-host routing.
  4. Request a temporary PHP health endpoint, confirm the expected interpreter, and remove the endpoint after testing.
  5. Log in to the database with the WordPress user and verify that access is limited to the application database.
  6. Run wp core version --path=... as the site user and run wp core is-installed --path=... to confirm the tables exist.
  7. Request the HTTPS site and check redirects, certificate validity, login access, uploads, and permalink behavior.
  8. Run Ansible again and require a clean convergence report.

Keep health checks free of secrets. If a check fails, preserve service logs and the exact Ansible task output, but ensure Vault variables and command lines containing passwords are redacted.

Security controls that belong in automation

Transport and host protection

  • Use SSH keys, a dedicated deployment account, and narrowly scoped sudo policy.
  • Enable HTTPS with automated renewal, redirect plain HTTP, and open only required firewall ports.
  • Apply Ubuntu security updates through a tested maintenance process; do not hide patching inside an unpredictable application bootstrap.
  • Restrict database binding and network access to the application path.

Application and filesystem protection

  • Use a dedicated database and database user; never reuse the server’s root login.
  • Keep wp-config.php unreadable to unrelated users and avoid world-writable directories.
  • Separate uploads from executable code where your web-server policy permits it, and review plugin and theme write requirements.
  • On multi-site hosts, prefer per-site Unix users and PHP-FPM pools over blanket ownership by www-data.
  • Store Vault passwords outside the repository and rotate database and administrator credentials through controlled changes.

Backups, updates, and rollback

An installation is not recoverable merely because the playbook can run again. Schedule database dumps, protect them separately from the host, and test restoration. Back up the uploads directory and any configuration or custom code that is not recreated from version control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Update WordPress, plugins, themes, PHP, and the operating system in staged environments. Record the application and database versions before each change. For safer rollbacks, deploy WordPress into versioned release directories, keep uploads on a persistent path, and switch a symlink only after health checks pass. A database schema migration may not be reversible, so take a backup before updates and document the forward-recovery procedure.

Troubleshooting common failures

Symptom Likely cause Fix
Package task cannot find PHP or extension Ubuntu release uses a different package name or repository Inspect the target release’s package metadata, adjust the role variables, and test on that release rather than copying an older command.
Database module reports an authentication error Wrong socket, driver, administrative account, or authentication plugin Verify the socket path and Python driver, test a local administrative login, then create the application user separately.
WordPress shows “Error establishing a database connection” Incorrect host, name, user, password, or database grant Test with the same credentials from the managed host, inspect grants for the exact host value, and confirm Vault variables were loaded.
Apache returns the default page Virtual host is not enabled, DNS points elsewhere, or the request lacks the expected host name Check enabled sites, reload Apache, inspect the resolved address, and send a request with the intended host header.
Permalinks return 404 under Apache Rewrite support or directory overrides are disabled Enable the rewrite module, permit the required overrides for the document root, reload through the handler, and resave permalinks.
WP-CLI command works manually but not in Ansible Different user, path, PHP binary, environment, or file permissions Run the command as the owning site account with an explicit --path, inspect wp --info, and remove interactive assumptions.
Second run reinstalls or changes files Unpinned download, missing guard, or ownership drift Pin a checksum, add state checks, use stable release paths, and decide which account is authoritative for each directory.

When to use a different implementation

Choose the Apache path when it matches your Ubuntu fleet and you want the smallest operational surface. Choose Nginx with PHP-FPM when you already standardize on it or need per-site pools and tighter process isolation. Keep WP-CLI for repeatable environments; reserve browser setup for a deliberate manual fallback. Use a managed database when its backup, failover, and security controls outweigh the latency and network complexity of a local server.

The durable pattern is the same in every variant: declare inputs, encrypt secrets, create least-privilege database access, template configuration, notify reload handlers, bootstrap only when state is absent, and prove convergence with a second run and application-level checks.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.