September/October 2018 – How To
Let’s create a local copy of your WordPress website to use as a dev site.
Here’s my thinking.
Everyone visiting the WordPress SIG, by definition, has some level of interest in WordPress. Whether you like to build WordPress websites in your spare time, or you do it professionally, maybe you maintain a website for an organization you volunteer for, or are kicking the tires on a new hobby, we all share one common interest – WordPress websites.
For the September meeting we will be making a copy of an existing live website, aka a ‘production’ website, to create a ‘development’ website. The development, or dev site, is where we will make changes to our website to preview the new functionality, or design, before making those changes to the production site. Changing untested code on a production website, mockingly referring to as Cowboy coding, is strongly recommended against.
To create our dev site we are going to use the following tools:
- Local website server – Local by Flywheel
- Adminer Database Management – included/installed with Local by Flywheel
- FTP Client – Filezilla
- Database Migration Plugin – WP Migrate DB
- Text Editor – Visual Studio Code
Local by Flywheel ‘local’ is a big download. If you want to use this during the session, please download the file and install it prior to attending the SIG meeting. We will not go over the download and install of the local server on your development computer. Local runs on both Mac and Windows, as do each of the other tools we will be using.
Steps we will take.
- Create development website in Local by Flywheel
- Set site name to be similar to your live website
- Set username and password to match live site (trust me)
- Log into your dev website
- Install and activate WP Migrate DB plugin from the WordPress repo
- Browse to Tools | WP Migrate DB | Migrate
- Note the ‘Find’ settings for new URL & file path
- Configure the migration plugin
- Log into your production website
- Install and activate WP Migrate DB plugin
- Browse to Tools | WP Migrate DB | Migrate
- Copy ‘Find’ settings from dev site WP Migrate DB to live site WP Migrate DB ‘Replace’ URL & file path
- Click ‘Save Migration Profile’ on live site
- Run migration export of database
- Click ‘Export & Save’ at the bottom of the Migrate DB ‘Migrate’ tab. The export will begin. The tables being processed will be displayed. When all tables are written tot he export file, it will automatically download to your local computer.
- Copy content to dev site
- Using FileZilla FTP, we drag the content from the live site to the local dev site. Copy the following folders
- wp-content/themes/<your current active parent theme>
- wp-content/themes/<your current active child theme (if using child theme)>
- wp-content/plugins/ (This may take a LONG time)
- wp-content/uploads/2018/
- wp-content/uploads/2017/ (as needed)
- Using FileZilla FTP, we drag the content from the live site to the local dev site. Copy the following folders
- Set active theme
- In your local WordPress website dashboard, browse to Appearance|Themes and select website theme
- Import live database into dev site
- Live site database has been exported and downloaded to local computer with file name ending in .sql
- Visit Local By Flywheel portal, click on the ‘DATABASE’ menu item for your local website copy
- Select ‘ADMINER’. This opens a MySQL database management tool very similar to MyPHPAdmin
- From left side panel, select “Import”.
- In right side panel, select ‘Choose Files’, browse to the just-downloaded .sql file containing your live site database export.
- Select ‘Execute’. Depending on the size of your database this may runs only a few seconds or could take a few minutes. When it complete you will see a ‘Success’ message at the top of the right panel. You did it.
- Flush Rewrite rules
- In your local WordPress website dashboard, browse to Settings|Permalink. Note that you DO NOT need to save anything to flush rewrite rules. You only need to visit this page.
- Visit front end of dev site
We filled in the details during our gathering. I understand we went a little fast. I recorded a video of the process so that you have an opportunity to see it again, this time being able to stop, rewind, and review it on your own. The video is being presented at the October meeting.
Here is a link to the full September presentation.
This year will be filled with a selection of ‘How To’ topics combined with a sprinkling of WordPress best practices for website development and on-going maintenance. We will talk about optimizing your website for search engines, and take another look at plugin development and step into building our own WordPress starter theme.
A few resources were highlighted in the video. All of these resources are included in the presentation linked above.
Resources:
- Article: https://premium.wpmudev.org/blog/migrate-wordpress-wp-migrate-db-plugin/
- Flywheel by Local: getflywheel.com
- Gist: local-media-files-from-prod.sh
- Plugin: https://wordpress.org/plugins/wp-migrate-db/
- Photo Credit: Flying ducks by Gareth Davies on Unsplash
One final note. Our October PACS meeting is scheduled for Saturday, October 27, the 4th Saturday in October. I will not be at PACS that day as I will be participating in the Philly WordCamp. John Davey has graciously offered to step in and show the video.
See you in November.