Configure WordPress#

Apache#

Follow the Configure Apache documentation, using the wordpress configuration at the Add sites step.

In the service’s Pillar file, add, for example:

apache:
  public_access: True
  sites:
    coalition:
      configuration: wordpress
      servername: www.open-spending.eu
      serveraliases: ['open-spending.eu']
      context:
        user: coalition
        socket: /var/run/php/php-fpm-coalition.sock

MySQL and PHP#

Follow the Configure MySQL and Configure PHP documentation.

PHP-FPM#

Configure PHP-FPM to correspond to the Apache configuration. For example:

phpfpm:
  sites:
    coalition:
      configuration: default
      context:
        user: coalition
        listen_user: www-data
        socket: /var/run/php/php-fpm-coalition.sock

Note

You can create a custom configuration, if needed.

WordPress#

Note

Salt contains WordPress states, but they are limited. Also, WordPress is often deployed by copying files, rather than via fresh installs.

  1. Configure WP-CLI. In the service’s Pillar file, add, for example:

    wordpress:
      cli_version: 2.7.1
    
  2. Deploy the service.

  3. Connect to the server as the WordPress user (e.g. coalition).

  4. Change to the public_html directory:

    cd ~/public_html
    
  5. Download WordPress:

    wp core download --locale=en_US
    
  6. Configure WordPress’ database connection, to correspond to the MySQL configuration. For example:

    wp core config --dbname=DBNAME --dbuser=USERNAME --dbpass=PASSWORD
    
  7. Install WordPress, with a siteadmin user associated to sysadmin@open-contracting.org. For example:

    wp core install --url=www.open-spending.eu --title="www.open-spending.eu" --admin_user=siteadmin --admin_password=PASSWORD --admin_email=sysadmin@open-contracting.org --skip-email
    
  8. Uninstall default plugins:

    wp plugin uninstall hello
    
  9. If you have a custom theme, download and activate it. For example:

    git -C wp-content/themes/ clone https://github.com/open-contracting-partnership/www.open-spending.eu.git
    wp theme activate www.open-spending.eu
    

Migration#

When migrating domains or renaming themes, you might need to search and replace items in the database, using the wp search-replace command.

  1. Run the command with the --dry-run flag, for example:

    wp search-replace --report-changed-only --all-tables --precise --log=/tmp/wp-search-replace.log --dry-run 'open-spedning-coalition' 'www.open-spending.eu'
    
  2. Read the log file to check that no undesired replacements will be made:

    less /tmp/wp-search-replace.log
    
  3. Run the command without the --dry-run flag.

Strings to replace might include:

  • Developer email addresses

  • Domain names

  • Theme names

  • File paths

If the site uses these plugins, perform these operations to remove old items in the database:

  • Rank Math: Status & Tools menu item > Database Tools tab > Click the Delete Internal Links and Clear 404 Log buttons.

  • WordFence: Scan menu item -> Click the START NEW SCAN button. You can also manually delete rows from the wp_wfhits and wp_wflogins tables.