This is single.php

9 Step Near Painless WordPress Deployment

This is content-single.php

9 Step Near Painless WordPress Deployment

WordPress deployment.

Gut wrenching.

Usually.

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?

A nightmare.

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 wp-config.php File
  • 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

That’s right.

You’ll grab your most handy FTP program and rocket them up onto the Internet.

I recommend you use Panic’s Transmit.

It’s powerful.

It’s clean.

It syncs.

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.

Local Files of A WordPress Install

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:

Access mySQL on MAMP

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’.

Export SQL Database From PHPMyAdmin

Export SQL Database From PHPMyAdmin

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,MySQL Database Wizard or some such thing.

Click it and follow the instructions for crafting a new database.

Accessing CPanel Through Your Host's Customer Portal

Access MySQL through Cpanel

Create 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.

You should be using something like 1Password or LastPass to generate and store these passwords safely.

Create a New SQL User

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.

Import Your SQL Database for WordPress Installation

Step 7: Tweak Your WordPress wp-config.php File

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).

Change DB_NAME to the name of the database you created in step 3.
Change DB_USER and 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.

Else…

Step 8: Seek-And-Replace Those Outdated Links

Well not really outdated…

The database you imported has all its links for localhost… like localhost:8888/mysite.

To swap all mentions of “http://localhost:8888/mysite” over to “http://mysite.com”, you can use this search and replace tool for example.

Type in http://mysite.com/searchreplacedb2.php to run the tool.

Then…

  • Click Submit
  • Click Submit DB details

When it asks you what tables to search you make sure they’re all selected (greyed in).

  • Click Continue

Now do the replacement.

Search And Replace DB

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.

Search and Replace SQL Database

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.

Sincerely,

Sunny Lam

Writing from north of the Beaches
Toronto, Ontario
Canada

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

Comments insertion starts here.

Leave a Reply