Showing posts with label WordPress. Show all posts
Showing posts with label WordPress. Show all posts

Sunday, October 1, 2023

WordPress - How to Migrate Site to new Server

 Scenario:  Migrate WordPress Sites from Ubuntu LAMP Server to a new Host

For years I have hosted some family WordPress sites on a Cloud server.  Needing to both upgrade it and move it to a new Cloud location, necessitated transferring the websites to a new host and not simply migrating the server.  There were multiple factors that led to this approach and I'm sure several ways to solve this problem.  However, I have needed to determine a good way to back up WordPress sites and a documented method of migrating test sites to production.

What I found that worked for me was the following steps and using the plugin (Duplicator).  I have now migrated numerous sites using this method both from on-prem servers and from cloud to cloud.

STEPS:

  • Setup new location (LAMP Server)

  • Create a new database and database user (on the new server) that will be used for the website.  

    • Does not need to match the old website/database. Data will be imported into the new database.

    • Database Config
      • $ sudo mysql -u root

      • Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

      • mysql> CREATE DATABASE newdatabasename;

      • mysql> CREATE USER newdatabaseuser@localhost IDENTIFIED BY '<your-password>';

      • mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER

      •     -> ON newdatabasename.*

      •     -> TO newdatabaseuser@localhost;

      • I ran into problems with one import and it required that I "GRANT ALL" to the newdatabaseuser for the full import of the website to work.

      • mysql> FLUSH PRIVILEGES;

      • mysql> quit


  • Create a new folder in the new location (/var/www/newsite)

  • Install “Duplicator” Plugin on the current site

    • Run Duplicator and create a package

    • On Some older Mysql installations, I had to change the following setting

      • Duplicator -> Settings -> Packages -> SQL Mode -> 

        • Change from Mysqldump to PHPcode

  • Download both the .zip and installer.php files to my local machine

  • SCP -> New Server/Location

    • You can use whatever method you want to move the files from the server to the new host/server.
  • Copy both files to the new directory on the new server

  • Unzip .zip file or when you run the the Installer.php file, it will ask for the .zip file and unzip it as part of the installation process.

  • Change ownership & permissions on the new location (before running the installer.php)

    • chown -R www-data:www-data /var/www/newsitelocation

    • chmod -R 755 /var/www/newsitelocation

  • Run Installer (installer.php)

Sunday, March 28, 2021

Ubuntu 20.04 - LAMP Server (DigitalOcean), Apache 2.4, MySql 8, PHP 7.4.3 & WordPress 5.7

Overview - I installed a new Ubuntu marketplace instance on DigitalOcean that was designed for a 1-click install of a full LAMP server.  The system was up minutes later, however, the configuration became a bit more complicated than I had experienced just a day previous with Debian, its MySQL variant, and PHP 7.4.

Due to experiencing multiple issues I wanted to document what I experienced for historical sake.  

MySQL syntax for user creation and database permissions (GRANT) in version 8 are different.  For someone who is a DBA or hardcore MySQL user, this likely wouldn't be an issue, but it took more than an hour of googling to find the correct information, which turned out to be several issues.  Much of what I found was partially accurate creating greater confusion but in the end, I found syntax that worked correctly.

  • Make sure you create the user and its accompanying password, then Grant access to a given database.  Previously I had done this in one long command. Also, for some reason, I was not able to use 'localhost' and needed to use '%'.  And when trying to "grant privileges", I received this error "ERROR 1410 (42000): You are not allowed to create a user with GRANT"
    • Example Solutions

      • create user 'mysqluser'@'%' identified with caching_sha2_password by 'asecurepassword';
      • grant all privileges on database.* to 'mysqluser'@'%';

  • PHP & MySQL - I believe this next issue has to do with the version of PHP you are running and what authentication method is enabled.  I know there are various articles that speak to how and why etc, but I COULD NOT get my new database user accounts to connect and in the end, this MySQL command resolved my issues and allowed my WordPress user account to connect and one for phpmyadmin.
      • alter user 'mysqluser'@'%' identified with mysql_native_password by 'asecurepassword';


NOTE:  I believe the MySQL "alter" command above would assist someone experiencing similar issues following a MySQL upgrade from a version prior to 8.  

1/14/2023 

Ran into issues with "grant" commands.   
ERROR 1410 (42000): You are not allowed to create a user with GRANT

The following syntax corrected my issues.

CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'superSecretPassword!123';
GRANT ALL ON `database`.* TO 'user'@'localhost';



Tuesday, August 18, 2015

WordPress & PhotoGallery Plugin Tips

After installing WordPress and adding the PhotoGallery Plugin, I ran into an upload issue.  Sadly the plugin did not provide any errors to indicate that there was an issue.  It simply acted as if it had finished but never auto generated the thumbnails or properly uploaded the photos.

As a troubleshooting measure, I installed another "Gallery" plugin.   As luck would have it, it provided server statistics AND gave a warning, stating that due to my current settings, I would likely encounter a problem uploading photos.  This was VERY helpful and I quickly found the settings that needed to be changed in my PHP.ini file (see settings below).  I would have continued with this plugin but found the lite version to be very restricted and not as user friendly.  So I reactivated the PhotoGallery plugin and it now works as expected.

PHP.ini Settings:

1upload_max_filesize = 64M
2post_max_size = 64M
3max_execution_time = 300