How to migrate a wordpress website

  Others-其他

Install the wordpress related components on the new Server

  • Check upgrade in Ububtu
  • Installed Apache和MariaDB

root@XSHQSECS02:~# apt-get install apache2 mariadb-server mariadb-client

  • Start Apache and MariadDB also enable it in start up

root@XSHQSECS02:~# systemctl start apache2

root@XSHQSECS02:~# systemctl enable apache2

root@XSHQSECS02:~# systemctl start mariadb

root@XSHQSECS02:~# systemctl enable mariadb

  • Config MariaDB

root@XSHQSECS02:~# mysql_secure_installation

  • Install PHP and other depends packages

root@XSHQECSS01:~# apt-get install php php-mysql php-cgi php-cli php-gd phpMyAdmin

  • Generate public key on the new server, then copy it to the authorized key to old server.

root@XSHQSDO03:~# ssh-keygen -t rsa -b 4096 -C XSHQSDO03

  • Then verify that you’re able to connect to the old server from the new server using SSH.
  • Copy all the files from the old Web server

root@XSHQSDO03:~/.ssh/wordpressbak# scp -r 139.59.237.96:/var/www/* ./

  • Backup database from old server

root@XSHQSDO01:~# mysqldump -u DB_USER -p DB_NAME > export.sql

  • Copy the wordpress file to the correct directory and grant the access

root@XSHQSDO03:/var/www/html# cp -r /root/wordpressbak/html/* /var/www/html/

root@XSHQSDO03:/var/www/html# chown -R www-data:www-data /var/www/

  • Copy the database backup to the new server

root@XSHQSDO03:~/wordpressbak# scp -r root@139.59.237.96:/root/export.sql ./

  • Import the database

root@XSHQSDO03:~/wordpressbak# mysql -u wpdata -p ITWiki < export.sql

  • Restart all the services and testing browser the website

root@XSHQSDO03:~/wordpressbak# systemctl restart apache2

root@XSHQSDO03:~/wordpressbak# systemctl restart nginx

root@XSHQSDO03:~/wordpressbak# systemctl restart mariadb

LEAVE A COMMENT