Difference between revisions of "WordPress and Copying or Cloning a Website Manually"

Wiki.TerraBase.info
Jump to navigation Jump to search
(Created page with "...OK, you've got the perfect website. No, not the content, the Admin Stuff. All of the plugins, settings and other stuff. And now there's a new website you need for yourse...")
 
m
Line 1: Line 1:
...OK, you've got the perfect website.  No, not the content, the Admin Stuff.  All of the plugins, settings and other stuff.  And now there's a new website you need for yourself or your client.  Build the whole thing from scratch.  Nope.  Clone it, copy it, etc.  There are lots of tools out there to do just that.  Some are good, some are terrible.  If none of them work and you need to do it manually, here's how.
...OK, you've got the perfect website.  No, not the content, the Admin Stuff.  All of the plugins, settings and other stuff.  And now there's a new website you need for yourself or your client.  Build the whole thing from scratch.  Nope.  Clone it, copy it, etc.  There are lots of tools out there to do just that.  Some are good, some are terrible.  If none of them work and you need to do it manually, here's how.


This article is for experts.  There's no step by step with pictures.  Sorry.  It also assumes the use of Apache on CentOS.  But it also applies to other web servers like NGinx and other Linux flavors too.
This article is for experts.  There's no step by step with pictures.  Sorry.  It also assumes the use of Apache on CentOS.  But it also applies to other web servers like NGinx and other Linux flavors too. It is allso assumed you are proficient with web servers.  There are too many dumbed up websites that have so much crap I have to sort through when reading them, I thought it would be nice to have a tight neat site for experts without a bunch of useless extra stuff, just some command to refresh the 'ole memory


== The Steps ==
==The Steps==


* Copy the source sites Directory (and all the files) to a new Directory.  If using a Linux based web server, this is the safest way to copy things in that it preserves any symbolic links, etc: cp -ax WhatEverSourceDirectory WhatEverDestinationDirectory
*Copy the source sites Directory (and all the files) to a new Directory.  If using a Linux based web server, this is the safest way to copy things in that it preserves any symbolic links, etc: cp -ax WhatEverSourceDirectory WhatEverDestinationDirectory
* Set all the Directory and File permissions so the web server is happy and everything works;
*Set all the Directory and File permissions so the web server is happy and everything works;
** chown -R apache:apache DirectoryName
**chown -R apache:apache DirectoryName
** find FolderName -type d -exec chmod 755 {} \;
**find FolderName -type d -exec chmod 755 {} \;
** find FolderName -type f -exec chmod 644 {} \;
**find FolderName -type f -exec chmod 644 {} \;
* Export the database using the command line or phpMyAdmin (various methods and details here)
*Export the database using the command line or phpMyAdmin (various methods and details here: https://wordpress.org/support/article/creating-database-for-wordpress/)
*Create a new database;<syntaxhighlight lang="text">
mysql -u WhatEverUserName -p
...it will prompt for a password, type it in.
CREATE DATABASE WhatEverDatabaseName; (no dots / periods, underscores are fine)
GRANT ALL ON WhatEverDatabaseName.* TO 'WhatEverUser'@'localhost' IDENTIFIED BY 'WhatEverPassword';
FLUSH PRIVILEGES; 
</syntaxhighlight>
*Import the exported database file into the new database.  phpMyAdmin is the easiest way, but if it's a big database, watch out for PHP timeouts.
*Change all the references in the ''wp-config.php'' file from the old site and database names to the new ones, plus the user name and password for the database if it's different than the source website.
*Edit the wp_options Database Table, siteurl and home row values, changing them to the new website name.
*Create new virtual directory in the web server configuration files (this really glosses over quite a bit, but again, ).
**This includes log file loctions too
**Don't forget SSL stuff (Let's Encrypt, Certbot, etc.): certbot certonly (and remember if one just types ''certbot'' it scans the web server configuration files and then if one picks a number off the list Certbot will mess with the configuration files for the web server)
*Use a cool PlugIn named Better Search and Replace to find all instances of the old website name and change them to the new website name.
*
*

Revision as of 22:14, 30 November 2021

...OK, you've got the perfect website. No, not the content, the Admin Stuff. All of the plugins, settings and other stuff. And now there's a new website you need for yourself or your client. Build the whole thing from scratch. Nope. Clone it, copy it, etc. There are lots of tools out there to do just that. Some are good, some are terrible. If none of them work and you need to do it manually, here's how.

This article is for experts. There's no step by step with pictures. Sorry. It also assumes the use of Apache on CentOS. But it also applies to other web servers like NGinx and other Linux flavors too. It is allso assumed you are proficient with web servers. There are too many dumbed up websites that have so much crap I have to sort through when reading them, I thought it would be nice to have a tight neat site for experts without a bunch of useless extra stuff, just some command to refresh the 'ole memory

The Steps

  • Copy the source sites Directory (and all the files) to a new Directory. If using a Linux based web server, this is the safest way to copy things in that it preserves any symbolic links, etc: cp -ax WhatEverSourceDirectory WhatEverDestinationDirectory
  • Set all the Directory and File permissions so the web server is happy and everything works;
    • chown -R apache:apache DirectoryName
    • find FolderName -type d -exec chmod 755 {} \;
    • find FolderName -type f -exec chmod 644 {} \;
  • Export the database using the command line or phpMyAdmin (various methods and details here: https://wordpress.org/support/article/creating-database-for-wordpress/)
  • Create a new database;
    mysql -u WhatEverUserName -p
    ...it will prompt for a password, type it in.
    CREATE DATABASE WhatEverDatabaseName; (no dots / periods, underscores are fine)
    GRANT ALL ON WhatEverDatabaseName.* TO 'WhatEverUser'@'localhost' IDENTIFIED BY 'WhatEverPassword';
    FLUSH PRIVILEGES;
  • Import the exported database file into the new database. phpMyAdmin is the easiest way, but if it's a big database, watch out for PHP timeouts.
  • Change all the references in the wp-config.php file from the old site and database names to the new ones, plus the user name and password for the database if it's different than the source website.
  • Edit the wp_options Database Table, siteurl and home row values, changing them to the new website name.
  • Create new virtual directory in the web server configuration files (this really glosses over quite a bit, but again, ).
    • This includes log file loctions too
    • Don't forget SSL stuff (Let's Encrypt, Certbot, etc.): certbot certonly (and remember if one just types certbot it scans the web server configuration files and then if one picks a number off the list Certbot will mess with the configuration files for the web server)
  • Use a cool PlugIn named Better Search and Replace to find all instances of the old website name and change them to the new website name.