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

Wiki.TerraBase.info
Jump to navigation Jump to search
m
Line 3: Line 3:
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
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


== Quick S (Quick Summary) ==
==Quick S (Quick Summary)==
A list of all the major steps
A list of all the major steps


* Directories and Files;
*Directories and Files;
** Copy from Source to Destination
**Copy from Source to Destination
** Set proper Apache Ownership and Permissions
**Set proper Apache Ownership and Permissions
* Database;
**Search ''contents'' of Files for any references to old / source website
** Export Source / Import to Destination (new Database)
*Database;
** Modifiy wp_options Table, option_value Column for siteurl Row and home Row
**Export Source / Import to Destination (new Database)
* CleanUp;
**Modifiy wp_options Table, option_value Column for siteurl Row and home Row
** Better Find and Replace WordPress Plugin / Utility
*CleanUp;
** WP Optimize (general cleanup)
**Better Find and Replace WordPress Plugin / Utility
**WP Optimize (general cleanup)


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

Revision as of 13:33, 1 December 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

Quick S (Quick Summary)

A list of all the major steps

  • Directories and Files;
    • Copy from Source to Destination
    • Set proper Apache Ownership and Permissions
    • Search contents of Files for any references to old / source website
  • Database;
    • Export Source / Import to Destination (new Database)
    • Modifiy wp_options Table, option_value Column for siteurl Row and home Row
  • CleanUp;
    • Better Find and Replace WordPress Plugin / Utility
    • WP Optimize (general cleanup)

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.