How to Copy a Live WordPress Website to a Local Mac with cPanel and MAMP

How to Copy a Live WordPress Website to a Local Mac

How to Copy a Live WordPress Website to a Local Mac with cPanel, MAMP and Hosts File Redirection

It is normally not a problem to make minor updates and changes to a live WordPress website online such as making blog posts. However if you need to perform more substantial updates and changes to a WordPress website you risk the possibility of bringing down the entire site if something goes wrong. You also risk the possibility of disrupting current users while performing significant updates and changes. Therefore it is often advisable to copy a live WordPress website to a local Mac (or PC) to perform significant updates, changes or development. In this blog post I’ll show how to copy a live WordPress website to a local Mac.

WordPress Web Development Resources on Amazon.com


Backup your Live WordPress Website to Your Local Mac

The first step in how to copy a live WordPress website to a local Mac is to make a backup copy of your live WordPress Website to your local Mac. This is something you should be doing periodically anyway to keep local backup copies of key milestones for your website. There are a number of different plugins you may use to do this from within WordPress itself. But if your web hosting provider uses cPanel to manage your account you can simply download a backup of your website using cPanel itself without cluttering up your WordPress installation with more plugins. cPanel allows you to easily backup your entire home folder which includes all WordPress content including WordPress itself, it’s current configuration, all plugins, themes and uploads. cPanel also allows you to backup your WordPress database which includes various settings, posts, pages and other content.

cPanel resources on Amazon.com

  • Log into your host account’s cPanel
  • Go to the Backup section
  • Click on the Home Directory button under Download a Home Directory Backup
  • Click on the name of your database under Download a MySQL Database Backup
    dreamlight_wordpress in this case

cPanel - How to Copy a Live WordPress Website to a Local Mac

  • Double-click the downloaded home directory backup archive in the Finder to decompress all the files.
  • Copy the entire public_html folder (which includes all WordPress files) to a local folder on your Mac. In this cas I I copied it to a Sites folder in my user directory (~/Sites). It’s important to copy the entire public_html folder rather than just the contents of the folder because you want to also copy the hidden .htaccess file inside that folder. If you just copy the contents it won’t copy that hidden file and you’d have to recreate it or copy it manually using the terminal. Copying the folder saves some steps.
  • Rename the copied public_html folder to the domain name of the live site, in my case DreamLight.com.

Download and Install MAMP (My Apache, MySQL, PHP)

  • Download MAMP from: https://www.mamp.info
    MAMP (My Apache MySQL PHP) Enables running local servers of Apache (& Nginx) MySQL and PHP to run WordPress locally on Mac or Windows. You can use the free MAMP version for one site at a time or upgrade to MAMP PRO for multiple sites and much more powerful features.
  • Click the MAMP Free Download button

MAMP Website - How to Copy a Live WordPress Website to a Local Mac

  • Download MAMP (& MAMP PRO)

Download MAMP - How to Copy a Live WordPress Website to a Local Mac

  • Install MAMP

Install MAMP - How to Copy a Live WordPress Website to a Local Mac

  • Click the MAMP icon in Launchpad to launch it

MAMP Icon in Launchpad - How to Copy a Live WordPress Website to a Local Mac-

  • Open MAMP Preferences

MAMP Preferences Menu - How to Copy a Live WordPress Website to a Local Mac-

  • In MAMP Preferences Ports tab click Set Web & MySQL ports to 80 & 3306

MAMP Ports - How to Copy a Live WordPress Website to a Local Mac

  • In MAMP Preferences Web Server tab set Document Root to the folder that you copied from the public_html folder, in this case: userx > Sites > DreamLight.com

MAMP Preferences Document Root - How to Copy a Live WordPress Website to a Local Mac

MAMP – Macintosh Apache, MySQL, PHP resources on Amazon.com


Create a New Local MySQL Database in phpMyAdmin

  • With servers running in MAMP, click on Open WebStart Page

MAMP Open Web Start Page - How to Copy a Live WordPress Website to a Local Mac

  • In the Tools menu select phpMyAdmin

MAMP Open phpMyAdmin

  • This launches phpMyAdmin
  • Under Create database type the same database name as the database you downloaded from the live site
  • Leave Collation menu alone. It will be set during WordPress installation
  • Click the Create button

phpMyAdmin-Create-Database

  • The new database appears in sidebar list

phpMyAdmin-Database

  • Then go to the Import tab
  • Click the Browse button and select the database that you had downloaded from the live site with the same name as the new database you just created

phpMyAdmin-Import

  • Finally scroll down and click the Go button. This may take a while if the database is large.
  • When the import finishes you should receive a message stating: Import has been successfully finished

phpMyAdmin resources on Amazon.com


Add a New Local MySQL User

We’re almost done with how to copy a live WordPress website to a local Mac. WordPress needs to know the name of the database along with a username and password to access the database. This information is stored in the wp-config.php file.

Open the wp-config.php file that you copied along with the live site files and locate the following lines which show your database username and password. [NOTE: Database/Username/Password displayed here have been changed for security purposes and is shown here for sample purposes only.]

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘dreamlight_wordpress’);

/** MySQL database username */
define(‘DB_USER’, ‘dreamlight’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password’);

If you create a matching username/password locally then you don’t need to edit this file and can more easily copy the site to/from the live site without having to edit settings all over the place.

  • In phpMyAdmin click on the Databases tab
  • Click on the Check privileges link next to the WordPress database
  • Then click Add user account in the New section at the bottom
  • Enter the User name and Password from the wp-config.php file

phpMyAdmin-New-User

phpMyAdmin resources on Amazon.com


Redirect Live Website Domain Name to Localhost

Once you know how to copy a live WordPress website to a local Mac you can redirect the domain name to access it. In order to access the new local copy of the website using the same domain name as the live website we’ll redirect the domain name to point to localhost on your local computer. This won’t affect what anyone else sees when they use the domain name from other computers. They’ll still go to the live website online. But when you use the domain name on your local computer you will see your local copy of the website instead. This will also mean you won’t need to change any URLs that may be in your database.

Here’s an article about how to edit the hosts file on Mac OS X. [One caveat about the process. If you use TextEdit to edit the file first open TextEdit’s preferences and in the Open and Save tab turn off the checkbox for Add “.txt” extension to plain text files. The hosts file won’t work if it’s named hosts.txt instead instead of just hosts.]

  • Add a line like this (using the domain name you wish to redirect to your localhost):
    127.0.0.1 DreamLight.com

Later when you want to go back to using the domain name to access the live site again just comment out the line you added in your hosts file by adding a number sign (#) to the beginning of the line using the same process.


DreamLight Can Design a Custom WordPress Web Site for You

WordPress Web Site DevelopmentNow that you know how to copy a live WordPress website to a local Mac you may want to hire a developer. If you are looking for a WordPress developer DreamLight can develop a custom WordPress website for you. We will work closely with your marketing team to update your existing Web site that may be outdated or to design a brand new custom WordPress Web site. We design all our custom WordPress Web sites to be fully responsive. This means the overall design layout automatically re-flows on-the-fly to take best advantage of all modern mobile devices. We can also create a wide range of integrated branded marketing content for your Web site to help it really stand out, including: 2D/3D digital design, illustration, animation, interactive multimedia or application development.

Contact us for more information about designing a custom WordPress Web site or to explore your specific needs.


If you enjoyed this tutorial please consider making a donation to fund more!



Request a Free Quote Today!

Winning Websites + Great Graphics

DreamLight wrote the book: Creating a 3D Animated CGI Short. See what we can do for you.

4 Responses

  1. Nai
    | Reply

    Hello,

    I’ve gotten all the way to the Add a New Local MySQL User section, but then I’m lost on what to do.
    I entered the User name and Password from my wp-config.php file. Then what? Do I need to click on anything? Am I done? Then, I kind of understand your section Redirect Live Website Domain Name to Localhost, but what exactly am I supposed to do here?

    • Hi Nai,

      I don’t currently have that installed at the moment to be able to check that screen for you. After you enter the username and password scroll down that page and see if there’s a button to enter/accept/etc. to create that new user. Does that help?

      Thanks,
      -MikeS

  2. Gail Sands
    | Reply

    Hello. This is 3 years later…
    I was gratefull to find your post, but I’m thinking it’s outdated for 2020.
    I cannot find a public.html file in the wp files I downloaded from my c-panel.
    Any suggestions?
    Thanks

    • Hi Gail,

      I’m not sure what you are referring to. There is no public.html file. Do you mean the public_html folder?

      Thanks,
      -Mike S

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.