Often times as developers we work on our local machines to put together our sites. When the time comes to deploy your site, and you're using Wordpress, the process can be complicated - with all the database migration, and all the pesky links!
Before using this method, I would do as I assume most WordPress developers would, and export the WordPress database from the Dashboard, and import that directly into the live site, and voila, done, right? Well not really. The WordPress export doesn’t really get everything, just the content-related tables, none of your settings, none of your plugins and their settings… nadda. So begins the long and annoying process of resource migration while you curse at your monitor wishing there was a way to do it all without that ache in your ass.
First, you will need two programs (You probably already have these, or something similar), but I recommend them, and the process we will be going through will be native to these apps:
MAMP installs a local server environment in a matter of seconds on your Mac, and is a strong PHP development environment.[/column][column padding=”true”]
Sequel Pro is a fast, easy-to-use Mac database management application for working with MySQL databases.[/column]
Tidy everything up. Make a copy and backup your existing project – just in case! I’m not going to go into crazy detail, but you did register a domain and set the hosting up for it?
Export the Database
Export the database using sequel pro. This will grab everything, which is crucial to a flawless deployment. To export a database, log into the Sequel Pro Socket connection, and select your database from the list.
Click: FILE > EXPORT
Make sure your settings are just like this. For the most part the defaults are fine and you don’t have to change them, just make sure it’s SQL, then export.
Because we’re migrating from localhost, the database will be full of references to http://localhost:8888/yoursite/. In order for our deployment to work, all those entries must be changed.
Open the newly exported database file, and do this find-change:
find/change - http://localhost:8888/yoursite/ to http://www.yoursite.com/.
Prepare your host
Set up a new empty database with your host. I use godaddy, so you would go to the Hosting Control Center -> Databases to add a new one.
Your process may differ, but either way we just want to ensure that we’ve done the prep work here. Once your database has been initialized proceed to the next step.
Open your new database in PHPmyAdmin, and open the Import page. Select the database we exported from your localhost, the same one we did the find-change on.
Leave all settings as default, and hit go. Give it a few moments to parse, and confirm that the import was successful.
Flip WordPress to work with its new home and new database in wp-config.php; open it up and input your database details: (dbname, user, pass, host).
At this point the site will be prepped and ready to deploy, and because we saved a backup copy (right?!?!) you can always go back if there is an error.
Upload your site
Grab everything, and upload it so that the root structure is the same as it was on your localhost. For example, If WordPress was installed in ‘wordpress/’ grab all the contents of the ‘wordpress/’ folder, and upload them to your root folder.
This may take quite a bit of time, depending on how large your site is and how much media you have, but go get lunch, or go read Smashing Magazine while you wait.
Just kidding. But if it all went to plan your new site should be fully operational.
Some things to check for:
- Hard coded urls using localhost in your template files.
- All your plugins are working as intended.
- Contact Form 7 forms will reset
- Some widgets will reset
At this point you should be done! Happy Blogging!