In this post, you will learn how to set up WordPress in your computer, so that you can develop and test your new features locally, before updating them into your live website.
You will also learn how to clone your live WordPress website into your local server, and how to clone the local WordPress to your live server. All this thanks to the Duplicator plugin.
After reading this post, you’ll be able to migrate your website from one url to another! As you just need to clone your website and install it in your new live server.
Install WordPress locally
Before installing WordPress on your computer, you need to install MAMP (which stands for Macintosh, Apache, MySQL and PHP). You can download it from its home page. If you are using Windows you can install WAMP, and in Linux, LAMP.
Once download it, open MAMP (not MAMP Pro). You should see the following window:
Go to Preferences… –> Ports to edit your port configuration. By default, the MAMP port for Apache is 8888 and for MySQL is 8889.
With this configuration, you’ll need to write http://localhost:8888 in your browser to see your local websites.
Note: If you want to make your local website available at the usual url http://localhost (without specifying the port number) you have to change the Apache port from 8888 to 80. However, the drawback of this action is that every time you start servers you’ll have to provide the admin password of your computer.
I’ll leave the default configuration and save the port-url in my browser’s bookmarks 🙂
Next, we need to specify the Document Root, i.e. the folder where we will create and store our website files.
OS X has two web document roots:
- /Library/WebServer/Documents and
- /Users/username/Sites (also accessible via ~/Sites)
In my case, the first one was created but not the second one.
In this tutorial, we will use the second document root folder, which we have to create. Open your terminal and type:
$ mkdir ~/Sites
to create the Sites directory (note: you can also create it using Finder).
Next, go back to the MAMP Settings and go to the Web Server tab (or Apache tab). There, you’ll have to specify the WordPress folder we have created as the Document Root of the web server (to change the folder you have to click on the folder icon next to the Document Root text).
Click OK to save this configuration and click Start servers to start both the Apache and MySQL servers. You’ll see the default MAMP start page on your browser (if not, type Open start page in the MAMP window). You will see something like:
Select the phpMyAdmin link and go to the databases tab. There, create a new database named wordpress:
You don’t need to specify a Collation, as MySQL will change it when creating your database tables, just type Create after writing the name of the new database.
Next, we have to download WordPress and unzip it into the Document Root we have specified (here, ~/Sites).
You can download WordPress from the website, or using your terminal:
$ cd ~/Sites
$ curl -O http://wordpress.org/latest.tar.gz
$ tar -xvzf latest.tar.gz
$ rm latest.tar.gz
this will automatically unzip its contents into a wordpress folder (you can change the name of this folder if you want to). The last command just removes the zip file.
Finally, visit your local host (here at http://localhost:8888), select your WordPress folder and follow the WordPress installation. Write the following information for the database setup (you can change it if you want to, but the database name has to be the same we entered in the PHP admin, here wordpress):
Click Submit and continue with the WordPress installation.
That’s all!! You are ready to use your WordPress installation locally!! 🙂
Clone your Live WordPress website to your Local server with Duplicator
We will use the Duplicator plugin to copy the live website into our local server. Go to the WordPress admin of your live website and install it from the plugin panel. Don’t forget to activate it.
In your WordPress admin left menu you’ll see that you have another option now, called Duplicator. Go there and click on Packages –> Create New
In this section you can control the details of your Package, but for now, the default values are just fine. Moreover, most of these settings can be changed when installing the package in your new server.
Click on Next to start a System Scan. You should have all the tests pass (green). Next, click on Build to create your package.
Once the package is completed, you should click on both Installer and Archive buttons to download the corresponding files. First, create a folder in the Document root to put both files there. For example:
$ mkdir ~/Sites/live_website
Note: packages are copies of your entire website. So if you have a large site, you’ll have to wait more to create the files and download them.
Next, we need to create a new database for the new WordPress installation. Go to the local PHP admin, and create a new database there following the same procedure as in the previous section. Here, we will call the new database live_website. If you don’t find the PHP admin, go to the MAMP app and select Open Start Page. There you will see the link to phpMyAdmin.
You are now ready to go to your local server, http://localhost:8888, and select the folder where you saved your website package (live_website). To begin with the installation, you should click on the installer.php file.
Here you have to select the host (localhost), the name of your database (live_website), the user (root) and the password (root). Note that your can create a new Database or connect to an existing database and remove all its data. As we just created the live_website database and it is empty, we can use the Create new database option.
You can click on Test Connection to detect any possible errors, check the box I have read all warnings & notices and click on Run Deployment.
In the next window, you’ll see the old website settings URL and Path, and the new ones. You can also change the website title or create a new admin account (although it’s not necessary), and even deactivate some plugin that you don’t want to work in your local server.
When you’re satisfied with the new settings, click on Run Update to create a clone version of your live website in your local server. You should see something like:
First, we don’t see any errors on Install Report. Next, click on Save Permalinks to log in into your local wp-admin and save the Permalinks settings. After saving, notice at the top of the page a warning message that tells you that you still have Duplicator’s files in the working directory. You can delete them from here, or you can go back to the Duplicator – Installer and type File Cleanup.
Finally, click on the Test Site link in the Duplicator – Installer page to see your site live. Did it work for you?
Upload local WordPress changes to your live Website
Ok, now we know how to make a copy of our online WordPress site in the local server. This is very useful because we can make all the changes and updates locally and test them before applying them into the deployment version.
But how do we upload the new version into the Live server?
Sometimes you only need to update a single file, like styles.css. For these cases, you can use a FTP client to update the file.
And other times you want to update the full website, in which case you can use again Duplicator.
Here, we will explore both scenarios.
1. Use FTP to upload files to your live Website
First of all you’ll need an FTP client. We recommend you download and install FileZilla, which is free and easy to use.
Once installed, open it and add your credentials at the top of the application. Your FTP credentials can be found in your hosting panel, and probably in your Hosting welcome email. Basically you’ll need the host, username and password.
After you click on Connect, you’ll see all your server files in the right panel of FileZilla’s dashboard. On the left one, you’ll see the files in your computer. This means you can move and copy files between your computer and your live server using just drag and drop! Nice!
2. Use Duplicator to upload your local website into your live server
Go to your local wp-admin and create a Duplicator package of your site (remember that you can easily install Duplicator using the plugin’s dashboard). To create a package, just go to the Duplicator’s tab and click on Create Package.
Remember to download both the Installer and Archive files and save them in your computer. This time, create a temporal folder to download the files, as we will use the FTP client to upload them into your server, and next delete them from your computer.
Open FileZilla and login to your FTP account. You just need to copy the installer and archive files into the folder that contains your current WordPress installation (in my case, the folder public_html). Remember that you just need to find these two files on the left panel and drag them into the right one (in the correct folder).
While these files are being copied, we will create a database for our website. Go to your web host provider, and create a new database there. I will explain how to create a database for the particular case of BlueHost, but if you are using another host, it should be something similar.
Go to your BlueHost cPanel –> Databases and create the database there. Name it whatever your want, for example defaultprefix_mysite, but remember the name.
Next, create a new user using the same database name, like defaultprefix_mysite, and add it a password.
Go to Add user to database and add your new user to your new database. Select all privileges and click on Make changes.
By this time, the installer and archive files should be up on your server. Before closing the FileZilla, delete the file wp-config.php in your live server wordpress folder.
Note: We are going to install a full WordPress site in the same location as your previous site. This means that when we finish this installation, we will delete all the contents on the installer.php folder and place the new ones there. So make sure you want to upload the local website into your live server! 🙂
Go to your website url and add it /installer.php. It should be something like mysite.com/installer.php.
You will be asked to write your database credentials:
- Host: localhost
- Name: defaultprefix_mysite (database name)
- User: defaultprefix_mysite (user name)
- Password: your password
Click on Test Connection to see if everything works, check the warning and notices box and click on Run Deployment.
Next, you’ll see your old URL and Path settings and the new ones. Check that are ok, and change your Site name if you want to. When you’re done, click on Run Update.
On the resulting page, you should see something like Errors: Deploy (0), Update (0), Warnings: (0). Click on Save Permalinks to update your permalink configuration and click Save Changes.
Click on Test Site to open your new website and check that it works!
And finally, click on File Cleanup to remove the Duplicator installation files.
That’s all! Now you can clone your live website into your local computer, make all the changes you need and clone it back to the server! You can even clone it back to a different server if you want to!
Was it useful? Please, share it with your WordPress friends! 🙂
Marina Mele has experience in artificial intelligence implementation and has led tech teams for over a decade. On her personal blog (marinamele.com), she writes about personal growth, family values, AI, and other topics she’s passionate about. Marina also publishes a weekly AI newsletter featuring the latest advancements and innovations in the field (marinamele.substack.com)