Changing WordPress versions in the Local by Flywheel app

[ Update 2017-11-29: There is now a dedicated script for the Local app available here: https://github.com/keesiemeijer/wp-local-version ]

Local is a free Mac app to develop WordPress locally. The beauty is you can very quickly change the development environment of a site. It enables you to swap between different types of servers and versions of PHP with a single click. The only thing you can’t change (from the user interface) is the WordPress version. This something you don’t do very often, but It got me thinking. I’ve written a script to install older versions of WordPress for VVV. And as it turns out it’s fully compatible with the Local app. It lets you easily change WordPress versions all the way down to 0.71-gold. There are however some simple steps needed to set it up.

Setup

You need to have a site installed and running in the Local app
Click the site in the Local app and see what the Site Path directory is.
Go to /app directory inside the Site Path directory and download the vvv-init.sh file from the WP Nostalgia repository.

curl -O https://raw.githubusercontent.com/keesiemeijer/wp-nostalgia/master/vvv-init.sh

Edit the following variables in the vvv-init.sh file to match the url and credentials of the WordPress site. You can find the database credentials values by clicking Database in the Local App.

# =============================================================================
# Variables
# 
# Note: Don't use spaces around the equal sign when editing variables below.
# =============================================================================

# Domain name
# Note: If edited, you'll need to edit it in the vvv-hosts and the vvv-nginx.conf files as well.
readonly HOME_URL="wp-nostalgia.dev"


# WordPress version to be installed. Default: "0.71-gold"
# See the release archive: https://wordpress.org/download/release-archive/
# 
# Use a version number or "latest"
WP_VERSION="0.71-gold"

# Remove errors. Default true
readonly REMOVE_ERRORS=true

# Database credentials
readonly DB_NAME="wp-nostalgia"
readonly DB_USER="wp"
readonly DB_PASS="wp"

# WordPress credentials
readonly WP_USER="admin"
readonly WP_PASS="password"

That’s it. You can now change WordPress versions very quickly.

Changing WordPress Versions

Warning: Changing WordPress versions with this script completely removes all your files in the site’s public folder and deletes the database before installing a new version.

Right click the site and choose Open Site SSH.

A terminal window will open. Go to the app folder by typing this.

cd /app

To install WordPress 4.2 type this

bash vvv-init.sh 4.2

If all went well it shows a message with instructions how to finish the install.

Finished Setup test.dev with version: 4.2!
Visit test.dev/wp-admin Username: admin, Password: password

Change the version number to install any other version found in the WordPress release archive.

Note To install WordPress version 3.8 or lower your site needs to be running PHP 5.3. You can change the PHP version for your site in the Local app.

3 thoughts on “Changing WordPress versions in the Local by Flywheel app

Leave a comment