fd Blog

Daniel Hilgarth on software development

Move Simple Wordpress Installation to New Server

On the old server

Create a database dump

sudo mysqldump -p wordpress > wordpress.dump

Copy data to new server

Copy the following to the new server:

  • database dump
  • Wordpress installation directory
  • Apache configuration

You can do this using these commands:

scp  wordpress.dump <user>@<new-server>:/location/on/new/server
scp -r /var/www/<wordpress-folder> <user>@<new-server>:/location/on/new/server 
scp /etc/apache2/sites-enabled/<config-file> <user>@<new-server>:/location/on/new/server  

On the new server

Create empty database

sudo mysql -p
create database wordpress;
grant all privileges on wordpress.* TO "wordpressuser"@"localhost" identified by "<password>";
flush privileges;
exit;

Restore the database

sudo mysql -p wordpress < wordpress.dump

Place the files in the correct folder

sudo mv /location/on/new/server/<wordpress-folder> /var/www/
sudo mv /location/on/new/server/<config-file> /etc/apache2/sites-available

Fix file permissions

sudo chown -R www-data:www-data /var/www/<wordpress-folder>
sudo chown root:root /etc/apache2/sites-available/<config-file>

Enable the site in apache

sudo a2ensite <config-file>
sudo service apache2 restart

Comments