WordPress

Server

Create a server (following the usual process).

Configure the Salt pillar (see existing WordPress sites for an example).

Create a MySQL database using fabric, Database.

To view the database on the server:

mysql --user=www_hatherleigh_info --password=MyPassword www_hatherleigh_info

Database

Backup database using phpMyAdmin

From Backing Up Your Database. Log into cPanel, then phpMyAdmin:

  • Export

  • Quick

  • Format SQL

  • Go

e.g. wpbackup.sql

Restore database

Copy the database backup to your server.

Restore the database:

mysql --user=www_hatherleigh_info --password=MyPassword www_hatherleigh_info < wpbackup.sql

Files

Tip

Downloading files directly to the server will save time downloading to your workstation, then copying back to the cloud.

Tip

Backing Up Your WordPress Files says, The important files to back up would be your wp-config.php file, which contains your settings and your wp-content directory (plus its contents) which contains all your theme and plugin files.

Find your FTP login details and log into your server.

Identify the folder containing your WordPress site e.g. public_html.

Tip

Depending on your site, you could download the whole of the site folder or just the wp-content folder and the wp-config.php settings file.

Use lftp to mirror the folder to your cloud server. You may need to install lftp`:

apt install lftp

Tip

The mirror_remote_directory_to_local_directory script works very well (copy in the misc folder for our customer). Remember to update your user name, password, host name and folder.

Set the initial permissions on your files:

chown -R www-data:www-data /home/web/repo/project/www.hatherleigh.info/live/

If you prefer not to use lftp, then wget should work:

wget -r -l 0 --ftp-user="user@name.co.uk" --ftp-password=abcdefgh ftp://72.720.72.72/public_html/*

Note

My user name was an email address. Using the separate parameters allows us to enclose this in double quotes.

Configure

SSL Certificate

Create an SSL certificate. I had to use a DNS challenge, LetsEncrypt - DNS, but next time, try:

init-letsencrypt www.hatherleigh.info - /home/web/repo/project/www.hatherleigh.info/live”

Config

Update wp-config.php:

# update the domain name
# vim ~/repo/project/www_hatherleigh.info/live/wp-config.php
define( 'WP_HOME', 'https://www.hatherleigh.info' );
define( 'WP_SITEURL', 'https://www.hatherleigh.info' );

Logging

Tip

Set the WP_DEBUG_LOG folder to a file within /var/log/wordpress/ e.g:: /var/log/wordpress/www_hatherleigh_info.log

From Example wp-config.php for Debugging:

# vim ~/repo/project/www_hatherleigh.info/live/wp-config.php
define( 'WP_DEBUG', true );
# Log folder (not in 'wp-content' as this is a security risk)
define( 'WP_DEBUG_LOG', '/var/log/wordpress/www_hatherleigh_info.log' );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
// define( 'SCRIPT_DEBUG', true );

Warning

It is a security issue to log to the wp-content folder, so make sure it is configured to another folder.

Check

Check your site health, https://www.hatherleigh.info/wp-admin/site-health.php?tab=debug

Filesystem Permissions shows whether WordPress is able to write to it’s own directories.

Mail

Follow instructions in postfix (check existing sites to make sure notes are up to date)!