Configure WordPress¶
Apache¶
Follow the Configure Apache documentation, using the wordpress configuration at the Add sites step.
In the server’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
This will:
Enable the proxy_fcgi Apache module
Install the PHP-FPM service
Create a
/var/log/php-fpm/coalition/log directoryCreate a
/etc/php/-/fpm/pool.d/coalition.confconfiguration fileInstall PHP packages
The configuration file enables log_errors and sets error_log to /var/log/php-fpm/coalition/coalition.log.
Configure logrotate for the log files:
logrotate:
conf:
php-site-logs:
source: php-site-logs
context:
php_version: '8.1'
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.
Configure WP-CLI. In the server’s Pillar file, add, for example:
wordpress: cli_version: 2.7.1
Connect to the server as the WordPress user (e.g.
coalition).Change to the
public_htmldirectory:cd ~/public_html
Download WordPress:
wp core download --locale=en_US
Create the
wp-config.phpfile, and configure the database connection, to correspond to the MySQL configuration. For example:wp config create --dbname=DBNAME --dbuser=USERNAME --dbpass=PASSWORD
Set WP_AUTO_UPDATE_CORE, to enable minor WordPress updates only.
wp config set WP_AUTO_UPDATE_CORE minor
Set DISABLE_WP_CRON, since system cron is used instead.
wp config set --raw DISABLE_WP_CRON true
Install WordPress, with a
siteadminuser associated tosysadmin@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
Tip
To list the cron jobs, run:
wp cron event list
Uninstall default plugins:
wp plugin uninstall hello
Add a must-use plugin to auto-update plugins for non-major versions only. For example, replacing
USERNAME:Note
WP Rocket can’t auto-update. See the changelog.
wordpress: sites: USERNAME: plugins: - auto-update-plugin
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.
Run the command with the
--dry-runflag, 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'
Read the log file to check that no undesired replacements will be made:
less /tmp/wp-search-replace.logRun the command without the
--dry-runflag.
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: