This article provides a step-by-step process for manually creating duplicate or specialized versions of your WordPress website, such as developer sites, staging environments, copies, or clones.
By following this guide, you can better understand how to clone your websites effectively, enabling you to efficiently manage various aspects of website development, testing, and customization to suit your needs.
If you need assistance cloning a website, our Solutions team can assist with purchased time.
Related Articles
SSH into Shared Server
SSH into VPS or Dedicated Servers
Make Backup
CAUTION: Before making any changes to your account, always make a backup!
- Access the server via SSH as the cPanel user or by using the Terminal in cPanel
-
Navigate to the site's document root using the cd command
cd public_htmlREPLACE: public_html with your domain's document root if different.
- Create a database backup
-
Go back one directory
cd .. -
Create a backup of the site files
tar -czvf ~/public_html_backup_$(date +%Y-%m-%d).tar.gz ~/public_html/REPLACE: public_html with the site's document root.
Create Site & Database
- Log into cPanel
-
Create a subdomain for the site to be cloned to
TIP: Some common subdomain names are dev or staging.
NOTE: This step is not needed if the site is being cloned to a different domain entirely. - From cPanel, navigate to MySQL Database Wizard and create a new database, database user, and assign permissions for the user to the database
Clone Site & Database
- Access the server via SSH as the cPanel user or by using the Terminal in cPanel
-
Navigate to the original site's document root using the cd command
cd public_htmlREPLACE: public_html with the original domain's document root if different.
-
Take note of the siteurl and home and whether the site uses HTTP or HTTPS
wp option get siteurl wp option get home -
Copy the files from the original site to the cloned site
cp -r ~/domain.com/* ~/dev.domain.com/REPLACE: domain.com/ with the original site's document root and dev.domain.com/ with the new site's document root.
-
Edit wp-config.php in the new site's document root
- Update the
DB_NAMEwith the new database name
EXAMPLE: You might replaceuserna5_wpwithuserna5_test. - Update the
DB_USERline with the newly created user - Update the
DB_PASSWORDline with the password assigned to the new user
- Update the
-
Import the database back from the original site to the cloned site
cd ~/dev.domain.com wp db import ~/domain.com_db_bkup.sqlREPLACE: dev.domain.com with the new site's document root and ~/domain.com_db_bkup.sql with the file path to the database backup created in the Make Backup Section.
-
Use the WP-CLI command to update the URL for the whole site
wp search-replace https://domain.com https://dev.domain.comREPLACE: https://domain.com with the old site's URL and https://dev.domain.com with the new site's URL.
NOTE: Use HTTP or HTTPS as determined in Step 3. -
Clear the WordPress cache
wp cache flush - Load the new site in your web browser to ensure it is loading properly
Comments
0 comments
Article is closed for comments.