The recent all-star “booster” training by Drew and Ryan handed me a fairly tried and true way to deploy a WordPress site with the least amount of hair pulling aggravation.
Before that I had to install WordPress on the host using Fantastico (typically for a newly minted domain).
Cloning SQL databases to the live site?
That was a few years ago.
Clearly I’ve come a long way.
So how can my recent experience deploying the Hotel Sunny Dallas 2015 WordPress theme help those new live WordPress deployments from scratch?
Well here’s the process in a nutshell…
- Blast Upload All Of your WordPress Files Onto the Live Server
- Export your local database
- Inflate (Create) A New Database On Your Production Server
- Create a new database username & password
- Make Sure The New User Can Access the Database
- Ship Your Exported Database To the Live Host/Production Server
- Tweak Your WordPress
- Run a find/replace tool on production database
- Clear the permalinks cache
It’s the 9 step process I just learned.
And it’s bloody straight forward.
Here’s how to use my sorcerous tweaks.
Step 1: Blast All Of your WordPress Files Onto the Live Server
You’ll grab your most handy FTP program and rocket them up onto the Internet.
I recommend you use Panic’s Transmit.
It has filters.
The GUI is easy to learn.
Of course if you don’t want to pay for it there’s always Cyberduck.
If your WordPress installation is setup on the production server, great — move on.
If not blast the files in your local WP install to their target.
This includes the child theme or theme files you worked on.
Step 2: Export Your Local Database
Prance into your PHPMyAdmin or use Sequel Pro that comes with MAMP or whatever local development environment or server you’re using.
If you’re using MAMP it looks something like:
Let’s say you use PHPMyAdmin…
Hop over to the Exports tab… choose the Custom Export method to be safe… make sure ALL the tables are selected and hit ‘Go’.
Step 3: Inflate A New Database On Your Production Server
Log into your web host, whoever they may be and march over to the CPanel if there is one.
If you’re with Digital Oceans I can’t help you however my titanic web dev acquaintance Dallas Koncir can.
Tell him I sent you his way.
Find a link or icon like
MySQL Database Wizard or some such thing.
Click it and follow the instructions for crafting a new database.
Step 4: Create Your New Database User Name and Password
You want to forge a new user name and password for every WordPress database you setup because using one name and one password for all your databases is like asking someone to hack you from the back…
… even though you heard them coming.
Use a strong password with a mix of numbers and characters.
This user name and password is what you’ll use in the
wp-config.php file of your deployed WordPress install so it can open the database door.
Step 5: Make Sure The New User Can Access the Database
In the above image you’ll see there’s a section to assign the new username to your new database.
Finish it off.
Step 6: Ship Your Exported Database To the Live Host/Production Server
The picture below says it all.
Step 7: Tweak Your WordPress
Easiest thing to do here is create a copy of your local version, rename it to
wp-config-local.php or something like that and keep that as your local backup for offline development.
Then tweak your actual
wp-config.php file either before you uploaded the installation or on the host server itself (open it from your FTP app in your fave text editor or use Transmit’s
Edit in Transmit).
DB_NAME to the name of the database you created in step 3.
DB_PASSWORD to the username and password created in step 4.
Vist your live site (“http://mysiste.com”) to make sure it’s connecting.
If you’re slapped by an error message go back and scan the
wp-config.php file for mistakes in spelling.
Step 8: Seek-And-Replace Those Outdated Links
Well not really outdated…
The database you imported has all its links for
To swap all mentions of “http://localhost:8888/mysite” over to “http://mysite.com”, you can use this search and replace tool for example.
http://mysite.com/searchreplacedb2.php to run the tool.
Submit DB details
When it asks you what tables to search you make sure they’re all selected (greyed in).
Now do the replacement.
Here’s an easy way to find the local link in the database…
Click into the
wp_posts table of your database, scroll right until you see the original links and you can view the original links used on your local offline server.
In the picture below I’ve already made the change so there’s nothing to see however you get the idea.
WARNING: Do NOT include the trailing slash in either URL. Do NOT include http:// when inputting your URL. Otherwise things could get messy fast.
- Click “Submit Search String” to run the replace.
WARNING: Once complete, head back to your FTP program and delete the
searchreplacedb2.php file from your server. If you want someone to change the lock on the door to your WordPress database, shutting you out then by all means don’t do this.
If all went according to plan the site should be working.
Step 9: Clear Your Permalinks Cache
Some might say it’s optional however I say you should always do it.
(I know I always do it.)
Just to be sure that WordPress is directing things to the right place and the right time.
Go to your admin dash, skip over to Settings > Permalinks and maybe hit Save.
Usually just opening the page is enough.
Again better to be sure so without changing anything simply hit Save or Update.
So that’s the painless way to deploy a WordPress site.
If you still have any questions send them my way.
Writing from north of the Beaches
Credit for the original process goes to Drew Minns, Ryan Christiani and the other amazing teachers and mentors at HackerYou. I may not always remember to say it in person however my thanks exists nonetheless.
Photo Credit: Heisenberg Media