#
How to migrate wordpress
By

Weslley Fernandes
#
Update wp-config.php
sudo vim /var/www/html/wp-config.php;
You need to change the "DB_HOST" definition for the new database endpoint.
#
Update site url.
UPDATE wp_options SET option_value = 'http://<NEW_URL>' WHERE option_name IN ('siteurl', 'home');
UPDATE wp_options SET option_value = 'https://<NEW_URL>' WHERE option_name IN ('siteurl', 'home');
#
Modify server names at nginx conf.
sudo vim /etc/nginx/sites-available/<domain>
sudo mv /etc/nginx/sites-available/<old_domain> /etc/nginx/sites-available/<new_domain>
sudo ln -s /etc/nginx/sites-available/<old_domain> /etc/nginx/sites-enabled/<new_domain>
sudo rm /etc/nginx/sites-enabled/<old_domain>
#
Generate certificate.
sudo certbot --nginx -d <domain>
#
Install WP CLI if not already installed.
cd /opt
sudo curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
#
Install PHP MySQL Extension if not already installed.
sudo apt install php<x.y>-mysql -y
#
Clean REDIS Cache.
redis-cli FLUSHALL
#
Restart NGINX and php-fpm services.
sudo systemctl restart nginx && sudo systemctl restart php<x.y>-fpm