Difference between revisions of "Move a Wordpress Website Manually"

Wiki.TerraBase.info
Jump to navigation Jump to search
m
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
Moving a Wordpress Website to another server consists of the following several steps
Manually moving a Wordpress Website to another server or another directory consists several similar steps.  All of the below assumes your server has the same services running like Apache, PHP, MariaDB / mySQL, etc.


*Make a copy of the Database: Using phpMyAdmin, Select the database in the left pane, Export Tab, "Simple" Radio Button, Go Button, save it to a file, done.
===Database===
*Make a copy of the Website Files: tar -cvzf /WhatEverDestinationFileName.tar.gz /WhatEverPathToSource/* (De-Compress: gunzip WhatEverFileName.tar.gz, tar xf WhatEverFileName.tar)
If moving to a different database server or changing the name of a database (for consistency or whatever);
**The .htaccess file presents a bit of an issue when "tarring", so copy it manually.
 
*Move or copy the saved database and website files to another server: rsync -vP WhatEverFileName UserName@URLorIPAddress:/WhatEverPath (rsync -vP switch is "verbose" and "progress meter")
'''Export the Database''': Using phpMyAdmin, Select the database in the left pane, Export Tab, "Simple" Radio Button, Go Button, save it to a file, done.
 
'''Create a New Database''': Use the following commands;
 
*mysql -u WhatEverUserName -p
*...then press enter and type in the database password
*CREATE DATABASE WhatEverDatabaseName;
*GRANT ALL ON WhatEverDatabaseName.* TO 'WhatEverUserName'@'localhost' IDENTIFIED BY 'WhatEverPassword';
*FLUSH PRIVILEGES;
 
...notice the semi-colon at the end of the above commands
 
Import the Database: Using phpMyAdmin, Select the database in the left pane, Import Tab, Browse Button to locate the exported file, Go Button (then wait).  Possible issues can occur here if different PHP time variables aren't set correctly.  Importing can also be done from the command line.  Just noting that here, it's simple to solve, but not addressed here, so don't worry or get frustrated, just Google the error.  Afterall, the original database still exists, so you haven't messed anything up.
 
If needed, also modify the database name in wp-config.php: define('DB_NAME', 'WhatEverDatabaseName');
 
===Copy the Files and set / check Permissions===
 
*If moving the website to a different server: Make a copy of the Website Files;
**tar -cvzf /WhatEverDestinationFileName.tar.gz /WhatEverPathToSource/*
**De-Compress: gunzip WhatEverFileName.tar.gz, tar xf WhatEverFileName.tar
**Copy the 'Zipped File' using one of the below methods
***If Samba is set up, use Windows Explorer
***rsync -vP WhatEverFileName UserName@URLorIPAddress:/WhatEverPath (rsync -vP switch is "verbose" and "progress meter")
**Note: The .htaccess file can present a bit of an issue when "tarring", so check it and copy manually if needed.
 
OR
 
*If moving to a different directory (it is assumed the root directory is /var/www/html, modifiy to suit your location);
**cp -ax WhatEverSourceDirectory WhatEverDesitnationDirectory
*
 
*
*Check or Correct Permissions and Ownership
*Check or Correct Permissions and Ownership
**chown -R apache:apache WhatEverDirectoryName
**chown -R apache:apache WhatEverDirectoryName
**find WhatEverFolderName -type d -exec chmod 755 {} \;
**find WhatEverDirectoryName -type d -exec chmod 755 {} \;
**find WhatEverFolderName -type f -exec chmod 644 {} \;
**find WhatEverDirectoryName -type f -exec chmod 644 {} \;
*If using Let's Encrypt SSL Certificates, move Certificates to the new server: /etc/letsencrypt/archive, live, renewal (there are symbolic links in the live directory): rsync -avzP /etc/letsencrypt/archive/ UserName@URLorIPAdddress:/etc/letsencrypt/archive/ (repeat for each directory, the "a" switch will preserve symbolic links, find . -type l -ls will display the symbolic links)
 
*Change DNS Settings
=== Web Server Configuration Apache, NGINX, etc. and DNS ===
*Configure new Apache Configuration File
Modify directory path names if needed.
*Configure any new directories necessary: Log Files for Apache, etc.
 
*Upgrade WordPress or change PHP version if needed, the former recommended.
Modify log file path names if needed.
*If any custom redirect files are used (redirect.html, redirect.php) to redirect HTTP to HTTPS, modify them
 
DNS: Make sure DNS records reflect any name changes.
 
=== WordPress ===
If making any changes to the name of the website, like www.WhatEverWebsiteName.com to WhatEverWebsiteName.com, then modify the following;
 
* wp-config.php: $web_site = 'WhatEverWebsiteName.com';
* Database: wp_options, siteurl and home, set to correct name if needed
 
=== SSL (really TLS), Certificates, etc. ===


All of the above assumes the new server has the same services running like Apache, PHP, MariaDB / mySQL, etc.
*If using Let's Encrypt SSL Certificates, move Certificates to the new server: /etc/letsencrypt/archive, live, renewal (there are symbolic links in the live directory): rsync -avzP /etc/letsencrypt/archive/ UserName@URLorIPAdddress:/etc/letsencrypt/archive/ (repeat for each directory, the "a" switch will preserve symbolic links, find . -type l -ls will display the symbolic links.


<br />
=== Redirects ===
If any custom redirect files are used (redirect.html, redirect.php) to redirect HTTP to HTTPS, modify them.

Latest revision as of 09:24, 27 April 2022

Manually moving a Wordpress Website to another server or another directory consists several similar steps. All of the below assumes your server has the same services running like Apache, PHP, MariaDB / mySQL, etc.

Database

If moving to a different database server or changing the name of a database (for consistency or whatever);

Export the Database: Using phpMyAdmin, Select the database in the left pane, Export Tab, "Simple" Radio Button, Go Button, save it to a file, done.

Create a New Database: Use the following commands;

  • mysql -u WhatEverUserName -p
  • ...then press enter and type in the database password
  • CREATE DATABASE WhatEverDatabaseName;
  • GRANT ALL ON WhatEverDatabaseName.* TO 'WhatEverUserName'@'localhost' IDENTIFIED BY 'WhatEverPassword';
  • FLUSH PRIVILEGES;

...notice the semi-colon at the end of the above commands

Import the Database: Using phpMyAdmin, Select the database in the left pane, Import Tab, Browse Button to locate the exported file, Go Button (then wait). Possible issues can occur here if different PHP time variables aren't set correctly. Importing can also be done from the command line. Just noting that here, it's simple to solve, but not addressed here, so don't worry or get frustrated, just Google the error. Afterall, the original database still exists, so you haven't messed anything up.

If needed, also modify the database name in wp-config.php: define('DB_NAME', 'WhatEverDatabaseName');

Copy the Files and set / check Permissions

  • If moving the website to a different server: Make a copy of the Website Files;
    • tar -cvzf /WhatEverDestinationFileName.tar.gz /WhatEverPathToSource/*
    • De-Compress: gunzip WhatEverFileName.tar.gz, tar xf WhatEverFileName.tar
    • Copy the 'Zipped File' using one of the below methods
      • If Samba is set up, use Windows Explorer
      • rsync -vP WhatEverFileName UserName@URLorIPAddress:/WhatEverPath (rsync -vP switch is "verbose" and "progress meter")
    • Note: The .htaccess file can present a bit of an issue when "tarring", so check it and copy manually if needed.

OR

  • If moving to a different directory (it is assumed the root directory is /var/www/html, modifiy to suit your location);
    • cp -ax WhatEverSourceDirectory WhatEverDesitnationDirectory
  • Check or Correct Permissions and Ownership
    • chown -R apache:apache WhatEverDirectoryName
    • find WhatEverDirectoryName -type d -exec chmod 755 {} \;
    • find WhatEverDirectoryName -type f -exec chmod 644 {} \;

Web Server Configuration Apache, NGINX, etc. and DNS

Modify directory path names if needed.

Modify log file path names if needed.

DNS: Make sure DNS records reflect any name changes.

WordPress

If making any changes to the name of the website, like www.WhatEverWebsiteName.com to WhatEverWebsiteName.com, then modify the following;

  • wp-config.php: $web_site = 'WhatEverWebsiteName.com';
  • Database: wp_options, siteurl and home, set to correct name if needed

SSL (really TLS), Certificates, etc.

  • If using Let's Encrypt SSL Certificates, move Certificates to the new server: /etc/letsencrypt/archive, live, renewal (there are symbolic links in the live directory): rsync -avzP /etc/letsencrypt/archive/ UserName@URLorIPAdddress:/etc/letsencrypt/archive/ (repeat for each directory, the "a" switch will preserve symbolic links, find . -type l -ls will display the symbolic links.

Redirects

If any custom redirect files are used (redirect.html, redirect.php) to redirect HTTP to HTTPS, modify them.