WordPress

How to Create a Local Version of Your WordPress Website Using MAMP and the WordPress Plugin UpDraft

Introduction

Having a local copy of your WordPress website is great when you want to develop new features without touching your live version. This is especially important when you do updates that are very complex and involve the modification of several files. For simple quick changes, you can probably stick with live until your website demands become greater over time. The best way to copy your website over to your computer for development is through the use of both MAMP and the WordPress plugin UpDraft.

What is MAMP?

MAMP is a program that is available for both Windows and Mac that allows you to run a web server on your computer. So you can run a local web server that allows you to do your web development offline. This is great for complex projects that might take a while to complete and require the modification of several files. If your website is still small and simple, then you can just FTP your files from local to live. Or, if you have a repository for large projects with multiple developers, then that is the ideal development environment. 

Why is MAMP Important for Local Web Development?

MAMP is important for local web development because without it you run the risk of not being able to update your website outside your admin console. So this means that your website will have to rely on plugins to do everything and they can only do so much until you need to modify files and something, even the database directly. 

Also, consider the possibility that you might introduce errors on your website if you make a mistake modifying a file incorrectly. This means that you will have to revert your changes and try to navigate around not introducing errors on live websites that have traffic. If people see these errors, they will think that something is wrong with your website and leave. This is very bad because losing traffic means that people may not return to your website if they end up finding what they need somewhere else.

What is the WordPress UpDraft Plugin?

The UpDraft plugin for WordPress is one of the essential plugins that I recommend for WordPress. This plugin allows you to create daily backups of your WordPress website in case something happens to it. If something does go wrong with your website, then you can restore your website to a state before the issue happened. A restoration should only be done if there is no one other option and your website is totally broken. If you can resolve it without having to perform a restoration, then that is the better option.

Having backups are also good for when you want to have a copy of your website that you can download in situations where you might lose your content. Not only in the case when serious errors occur, but when you just want to keep backups on your computer just to keep your website safe. 

Why is the WordPress Updraft Plugin Important?

Without the backup plugin, it is very hard to create backups of your website otherwise. Some web  hosts create backups for you already but you should also supplement those web host backups with UpDraft. Especially since you can download UpDraft backups, you can keep copies on your computer. The nice part about UpDraft backups is that they only give you the necessary WordPress files.

Here is what is contained in a UpDraft backup:

  • Database
  • Plugins
  • Themes
  • Uploads
  • Other

These are the only parts of a WordPress website that you need, the other files that UpDraft provides are not really crucial but you should take them anyway just to see if you even need them. In most cases, you can get by doing a WordPress migration without the other files. I usually consider these other files as miscellaneous.

Why Do I Need a Local Version of My Website?

You need a local version of your website for just tinkering with new ideas and have the ability to revert without touching the live website. Installing a proper local environment is part of good web development and is something that is expected of every decent web developer. Modifying live directly is acceptable for tiny small changes. Once you have a local environment setup, you must always start your web development locally and upload those changes to live. This is done either through a repository, or FTP. The reason why is because you need to keep your local and live environments in sync. If you do not strictly adhere to going from local to live for every change that you make, then your two environments will be out of sync and that will create problems when doing web development. Your changes going from local to live will not always look right and that could cause issues and errors on live.

Is Just Having a Live Version Good Enough?

For a simple blog that can thrive with just the admin console, yes you can stick with just the live version of the website. Just be sure to take backups and download them periodically if you feel the need to save your content. I would focus on saving the content, so that it is stored in the database or you can look into exporting your posts and pages and keep that in a safe place.

For more complicated websites, you will eventually hit a limit where plugins are not sufficient to make changes if you need an incredible amount of customization. Is it the customization of your theme that might lead you to needing a local environment to do web development. If you do not need theme customization, then maybe plugins are good enough for you.

How Do I Create a Local Version of My Website?

There are actually quite a few steps involved in creating a local version of your WordPress website. The trick is to do each step one-by-one and make sure that you complete the current step before moving onto the next one. The steps should be done in this order just to make sure everything is set before proceeding further.

Step 1. Download and Install MAMP: The Local Web Server Onto Your Computer

The first step is to download and install MAMP on your computer. You can choose between Windows or Mac. Once you install MAMP, you should know that there are four parts to running a web server.

Here are the four parts of running a web server:

  1. Operating System: Linux
  2. Web Server: Apache
  3. Back-end Programming Language: PHP
  4. Database: MySQL

You need to create a new folder in your MAMP installation under “htdocs” that will house your local version of WordPress. You should name the folder so that it matches the name of the website that you are copying over to local.

Turn on MAMP at this point because you need it to be on in order to access your local WordPress installation.

Step 2. Download a Fresh New Copy of WordPress Onto Your Local Environment

After you have a folder for your local version of your website, you should head over to WordPress.org and download the latest version of WordPress. You will install this version in your newly created local folder. When you download the WordPress files, make sure you extract the zipped file and take the files under the “wordpress” folder and move it under the new folder that you created in your local environment. Do not install WordPress just yet. We have stuff to do with the UpDraft plugin now.

Step 3. Use the WordPress Plugin UpDraft to Perform a WordPress Migration

Go to the UpDraft plugin in your website and create a backup of your current WordPress installation. Make sure to download every part of the backup. This includes the database, the plugins, the themes, the uploads and also the other folder. Save all of these files in the same location. By default, Chrome will download files in your “downloads” folder. Unzip all of the zipped files except the database. Leave the database file alone for now.

Take note that the larger your website, the larger the files will be. This means that it might take awhile to download all of the necessary files in order to perform a proper migration. By default, UpDraft splits their download files in chunks of 400 MBs. So be patient if it takes time to download everything. You cannot perform a proper and successful WordPress migration without every piece. Again, the other folder is extra, but just download it with everything else anyway.

Step 4. Create Your Local Database For Your WordPress Installation

You need to create a database before you can install WordPress. Go to PhpMyAdmin and create a new database for your local WordPress installation. 

You can find PhpMyAdmin for MAMP at this URL:

  • http://localhost/phpMyAdmin/

When you create the database, name it the same as it is on live because your database file from UpDraft is set up to import database records based on the database name. Just create the database for now, we will do the actual import later after we install WordPress.

Step 5. Update wp-config.php and Change the Database Settings

Before you install WordPress on your local environment, you need to update your wp-config.php file so that it points to your newly created database. Make sure to change the database name to the actual name of your database. Set database user and password to root and the database server to 127.0.0.1 or “localhost”. Both of those database servers should work.

Step 6. Run the WordPress Installation on Your Local

Now that your database is set up and your configuration file is set to point to it, you are ready to install WordPress. In order to access your WordPress website locally, go to “http://localhost/website”. When you access your website, you should be prompted to install WordPress. If you have installed WordPress before, then this should already be familiar to you. Go ahead and proceed with the installation. After installation is done, access your website and make sure that it works.

Step 7. Check to Make Sure Your Local WordPress Installation is Running Properly

Check both the front-end and login into the back-end to make sure that your newly installed WordPress website runs on MAMP. If everything looks good, then we are ready to move our files that we got from UpDraft over to the new WordPress installation.

Step 8. Move the UpDraft Files to Your Local Installation

Before you move any UpDraft files over, make sure to first make copies of your current plugins, themes and upload folders. After backups are created, delete those existing folders and move the ones over from UpDraft. You can find these folders under the “wp-content” folder.

Step 9. Import Your Live Database Into Your Local Database Using PhpMyAdmin

Return to PhpMyAdmin and first create a backup of your current database. 

You can create database backups in PhpMyAdmin using two different methods:

  1. Create a database copy and timestamp it with the current date
  2. Download an export of the database and save it on your computer.

For the purpose of migrating your live website over to local, you just stick with method one. This is better because if you download a database export, you need to keep track of it and separate it from the database files that you received from UpDraft.

Once you have your current database backed up, import the database file that you received from UpDraft into your database and that will copy over all of the records from live over to local. You are almost done! There were a lot of steps involved but you followed each exactly, your installation should have been successful.

Step 10. Access Your New Local WordPress Installation

The very last step is just to access your new WordPress installation with both the database and files copied over from UpDraft. If everything looks and works correctly, then you now have a working copy of your live website on local. Now you can make changes here and upload them to your live website via FTP. If you have a repository, then connect it to live. This article is focused on just doing a live to local WordPress migration.

Summary

A WordPress migration from live to local is only necessary if you have a complicated website that needs theme customization. You need to know web development since this kind of customization involves modifying code files and that is not as simple as just going through the admin and plugins. The steps can be pretty involved in performing a WordPress migration.

Tuan

Recent Posts

How To Fix Your Blog When Traffic Drops

Introduction I already wrote an article on what to do when your articles are not…

1 year ago

Lessons Learned from My Previous Attempt at Blogging

Introduction I have an old blog, www.stufftuanlikes.com. This was a hobby blog that I created…

1 year ago

What Happens If the Internet Disappears?

Introduction The Internet has changed our lives and I have written many articles about it.…

1 year ago

Writing and Reading Level: Writing to Cater to Your Audience

Introduction Writing even the most technical of subjects in a way that anyone in your…

1 year ago

Why You Should Start Your Blog Today

Introduction Blogging can be great fun and I have written several articles about my experience…

1 year ago

Why Is Online Documentation Still Lacking?

Introduction As a web developer, I rely heavily on documentation when implementing new solutions. When…

1 year ago