Tune WordPress
Published
Updated
Run WordPress on fortrabbit with an own domain, move its database, deploy changes with rsync, and manage it with WP-CLI over SSH, which is installed on every environment.
Adding a custom domain
WordPress first answers on the default domain. To go live on an own domain:
- Add the external domain to the environment and point its DNS to fortrabbit.
- Tell WordPress about the new domain:
Changing the site_url domain in the wp-admin
In wp-admin under Settings > General, set "WordPress Address (URL)" and "Site Address (URL)" to the new domain. Links stored in the content still point to the old address: replace them with wp search-replace (below), see moving WordPress.
Database migration
Most WordPress content lives in the MySQL database. Move it from the old host, up from local, or down from fortrabbit with export and import.
Deploying WordPress changes with rsync
rsync uploads only what changed, for example a theme folder, and is faster than SFTP.
Using the WP-CLI
WP-CLI is installed on every environment. Run it over SSH in the WordPress folder:
$ wp core version
$ wp plugin update --all
$ wp search-replace 'https://old.example.com' 'https://www.example.com'
See the WP-CLI commands.
Image sizes
WordPress creates every registered image size during the upload request. Themes and plugins add sizes, so one upload can mean many resized copies. Photos larger than the big image threshold of 2560 pixels are scaled down first. Keep the list of sizes short and uploads small.
WordPress has no queue of its own to move this to a background worker. The Image Processing Queue plugin creates the image sizes a theme requests through it in the background. We have not tested it, and its last release dates from 2017. See image transforms.
Running WordPress in a sub folder
For a blog under example.com/blog, install WordPress in a folder and set the "Site Address (URL)" accordingly, see give WordPress its own directory. For several WordPress sites, use one environment or app each, not folders in one environment.