wordpress workflow - from dev to staging to production - robert wilde

10

Click here to load reader

Upload: wordcamp-sydney

Post on 12-Apr-2017

428 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflowpresentation

#WCSyd 2016

Robert Wilde

Page 2: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

dev to staging to live

Development to Staging to ProductionFirst, big thanks to everyone who attended WordCamp Sydney 2016 and allthe awesome people who organised it. This event was my second this yearand my second time speaking, truly is the best event to attend.

It’s important to remember that everything I talked about on the day andoutline here is my way of doing things, not the way of doing things. There isno right way, only your way. I want to give you some ideas, and you seasonthem however you need to make it work for you.

In the post I will go over the same key points, I covered in my talk on the day. I will go over;

What the WordPress workflow includes.Why you should be using a workflow, even if you are not a developer.Some tools I use to make setting up and managing the workflow.

In future posts, I will go into more detail regarding some of my methods andtools.

What is the WordPress workflow?it is made of three environments:

Development

also called local, which runs on your computer/laptop and only accessible byyou.

Staging

WordPress Workflow - WCSYD 2016

Page 3: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - #WCSyd 2016

this runs on an available to the public using a unique URL, preventing anyissues with premature Google crawling and duplicate content. You can alsorestrict access via password if necessary.

Production

Also referred to as live, this is the final version.

The second factor is the direction of the flow from environment toenvironment. Initially, it should flow between each environment in onedirection. This is during a new site or project.

As you can see I added the definitive NO between DEV and live. At somepoint you will need to push from DEV to live but always ensure it has gonethrough the staging process first. I have a second application like, winSCp toupload from DEV to live to ensure there is no accidental overwrite.

There are times when you will need more two-way action, primarily whenyou are working on refactoring a live site. This is also the configuration to usewhen testing plugins or completing updates. You can sync live to stage, runupdates and tests, then complete on the live site.

WordPress Workflow - WCSYD 2016

Page 4: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - #WCSyd 2016

Why do you need this?These steps will a level of difficulty and add time to your process but forseveral good reasons.

Create and isolated sandbox to work on where you can safely makechanges without affecting end users.Allow you to make real-time comparisons between your job and the livesite.Test during business hours without affecting traffic or site services.

An important note or perhaps rule.NEVER, EVER WORK ON A LIVE SITE!

DON’T UPDATE PLUGINS!DON’T UPDATE THEMES!

DON’T MODIFY CODE!

WordPress Workflow - WCSYD 2016

Page 5: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - #WCSyd 2016

Now I demonstrated a key point to this rule during my session. I asked all theexperienced DEV’s in the room to raise there hand if they totally agree withthis, there where quite a few hands up. I then asked “Please keep your handraised if you have broken this rule, more than once?”. Fair to say almost nohands went down.

There are always exceptions to the rule. The point here is to make sure youare aware of the risks. Most people don’t know how bad fire is until they getburnt.

Some things to know when setting up yourWordPress workflow.Both your DEV or local environment and your staging environment should beconfigured the same as the live or production environment or whatis refereed to as the stack.

There are two main stacks used for WordPress.

LAMP – Linux, Apache, PHP, MySQLLEMP – Linux, NGINX, PHP, MySQL

If you don’t know what your live site is running on you can speak with yourhosting support to get more info. For the local DEV environment there areseveral tools to make this setup easy.

Quick install tools – WAMP, MAMP, XAMPP and Desktop ServerAdvanced tools – Vagrant (VVV or Chassis) , Docker, Linux VM &EasyEngine.

WAMP, MAMP, XAMPP and Desktop Server. I haven’t used these tools for awhile but have heard good things about Desktop Server as it has some toolsspecifically directed for WordPress setup.

WordPress Workflow - WCSYD 2016

Page 6: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - #WCSyd 2016

If you want something closer to the real thing with more tools and power,there are some tools that provide you with a Virtual environment. Theseinclude tools like Vagrant, specifically VVV or Chassis witch is actuallydeveloped and maintained by a fellow speaker Bronson Quick(@bronsonquick) and available on GitHub. Docker is another tool that isgaining massive traction and is OS agnostic or you go middle ground and usea vanilla Linux virtual environment like Ubuntu server LTS withan absolutely awesome CMD tool like easy engine. Witch is what I use. basicintro to EasyEngine.

If you are new to this stuff, please don not let the idea of command line scareyou. these more advanced environments gives a lot more control and powerwith tools like WP-CLI. If you don’t know WP-CLI put it on your list of thingsto read about. Lost count the number of times it has saved my bacon andmade things simple as it gives you access to DB import/export, plugin install,activate, deactivate and update, completing WP install/configuration and waymore. A little bit of time learning how to use it will save a massive amount oftime down the track.

More ideas for your WordPress work ow stagingenvironment.I believe it is important, if not vital, to use a dedicated WordPress hostingprovider for your Live hosting as they will generally provide you with astaging environment that is isolated. Isolated is important for when you aretesting and installing plugins, moving from live to staging and back again. Ifby chance something happens that causes a major problem it will not effectthe live site. Providers like WPengine, Pantheon or Conetix are great, theseare the ones I have looked at and played with.

What to look for when setting up a staging environment:

WordPress Workflow - WCSYD 2016

Page 7: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - WCSYD 2016

WordPress dedicated hosts may provide service as inclusion to hosting.AWS EC2 micro instance is a cost effective option.Create a dedicated custom domain for staging.

I personally do some things outside the box with Laravel PHP witch is why Istill have instances on Amazon AWS, they not hard to manage and very costeffective. I also play with Microsoft Azure virtual machines as well, they greatfor staging.

I have a created a dedicated domain for my staging. Keeps things easy for meto manage and I have issues with Google crawling this to early.

If you are running your own staging servers try and match the config or stackas close as possible as well as the location. You don’t want the hostingrunning in one country and the staging in another as it will produce someinteresting results when testing and doing demos with your client.

Finally I would try and avoid running your staging on the same VirtualPrivate Servers. Although it is rare you don’t want change something andcrash the server or you may need to reboot the server for some reason. Thatis not something you want to do to your production environment during theday. Might make some unhappy people.

Tools to help you move your data around.

Migrate DB Pro – https://deliciousbrains.com/

My number one favorite tool is Migrate DB Pro witch is fantastic for easilymigrating and moving the database from location to location. It takes care ofcompleting the URL renaming process making the DB migration seamless.Another great bonus is it will do a complete a backup before you sync so youcan roll back if needed.

WordPress Workflow - WCSYD 2016

Page 8: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - WCSYD 2016

The developer version also has some extra tools for migrating the uploadsdirectory and keeping it in sync. Once you have it in place it will only sync thechanged files saving a tonne of time.

Brad Touesnard and the team at Deliecous Brians, awesome name, have beenworking on a new tool called mergbot. This will allow you to actually sync thedatabase without overwriting so you merge your changes with the live site.Hopefully will be playing with sometime real soon.

WPCore – https://wpcore.com/

WP-core. This allows you to create a collections of plugins and then installthem all at once as well create a collection from an existing site and installthat collection on the other site. Basic intro to WPCore

UpdraftPlus WordPress Backup Plugin –https://wordpress.org/plugins/updraftplus/

Generally speaking the three most important things that come to mind whenworking with a WordPress site are Backup, Backup and Backup.

Tool I like for that is Updraft PLUS, even for general operation it is a greatbackup tool, offers fantastic revision capabilities. Allowing you to keep thelast x number of backups. Another great feature is its ability to separate filesand database. On a live site the database is what changes frequently sobacking that up daily and then backing up your plugins, themes and mediaweekly will save you a lot of space.

WordPress Workflow - WCSYD 2016

Page 9: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - WCSYD 2016

You can then set the plugins/uploads/themes to backup weekly or evenmonthly. Everything can be backed up off-site to AWS S3, Dropbox, GoogleDrive, Rackspace, FTP, SFTP, email. That is important, even you make regularbackups local so they are quick and easy to restore, always have at least amonthly off-site or downloaded just in-case, one-day you cant get to theserver.

ManageWP – https://managewp.com/

will post a walk through video soon

If you work with a lot of sites you should look at a management tool as thesehave awesome features including a clone feature, like ManageWP. It also hassome great tools for backup, site clone and migration, site up-time, plugin,theme and core updates plus a few more. When managing several WP sites,being able to access and manage the wp-admin from one place is priceless.

So that’s my take on the WordPress workflow. There are a tonne of otherareas to look at, like continuous deployment using git and online serviceslike SemaphoreCI or task runner tools like flightplan. Working my wayinto these items slowly but surely. I run a GitLab server in my office witchallows for builds and continuous deployment with git so will be testing thatsoon.

Really hope you get something from all this and if you have any questions,you know what to do. Keep on Developing!

WordPress Workflow - WCSYD 2016

Page 10: WordPress Workflow - From Dev To Staging To Production - Robert Wilde

WordPress Workflow - #WCSyd 2016

WordPress Workflow - WCSYD 2016