Skip to content

Instantly share code, notes, and snippets.

@tommymarshall
Last active March 24, 2016 14:59
Show Gist options
  • Save tommymarshall/774e8c882e15e0d986cb to your computer and use it in GitHub Desktop.
Save tommymarshall/774e8c882e15e0d986cb to your computer and use it in GitHub Desktop.
Launching a WordPress site

Bringing a Bedrock WordPress site live

Steps

1. Backup Database

Obligatory reminder to plan for the unexpected and give ourselves that peace of mind knowing we can restore what we messed up.

2. Deploy most up-to-date version

From your project repository, ensure that what is on production is up-to-date.

bundle exec cap production deploy

3. Delete cache and disable caching plugin

This ensures when your site does go live it doesn't serve a cached copy with old URL's in your markup.

4. Update Production deploy config

Update wpcli_remote_url in your config/deploy/production.rb to the production site UR. This allows subsequent deploys to correctly change all occurances in the database from your dev url (domain.local) to production URL (www.domain.com).

5. Update URLs on production

We need to replace all occurrances of the IP address, which is originally how we accessed production, to the new domain. To do this we'll use the WP-CLI tool we already have installed. You'll have to cd /var/www/domain.com/current/web to have it properly read WordPress configuration. Once there, run:

wp search-replace '166.78.62.108' 'domain.com'  --skip-columns=guid

Note: If we are routing traffic to www, you should normalize all URL's in the database. If we simply replaced "domain.com" with "www.domain.com", we could end up with a few "www.www.domain.com" in your database. So first:

wp search-replace 'www.domain.com' 'domain.com'  --skip-columns=guid # Normalizes URL's to non-www
wp search-replace 'domain.com' 'www.domain.com'  --skip-columns=guid # Convert all to www

6. Update .env

The shared/.env file on production, which defines the base of the permalink structure, must be updated to our new www.domain.com from:

WP_HOME=http://168.1.1.1
WP_SITEURL=http://168.1.1.1/wp

to:

WP_HOME=http://www.domain.com
WP_SITEURL=http://www.domain.com/wp

7. Test locally by updating your hosts file

Update your /etc/hosts file to point www.domain.com to the IP address of the production server. So, if our production server was 168.1.1.1, add:

168.1.1.1 www.domain.com

This will route traffic from www.domain.com to 168.1.1.1 and give an accurate representation of how the site would work live.

8. QA

Because of Step 7, visiting www.domain.com will actually route to our production server. From here, you can start general QA. Ensure that:

9. Update DNS

After ensuring everything is working properly, remove the overriding 168.1.1.1 line in your /etc/hosts and point your domain to the production server 168.1.1.1.

10. Ensure www.domain.com resolves and works as expected

11. Re-enable caching plugin

12. Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment