Migrate a WordPress site

I recently migrated all my sites from a mutualized hosting to a virtual private server (VPS).

Here are the steps to easily process with the migration.

Note: replace $username, $website, $etc. with your values!

Prepare the server

The server is a Debian installation, accessed over SSH.

Add a new user

  • add $username to sudo group line

Mysql

Create the database and the user for your new site.

Apache

Php

Migrate the WordPress site

It is possible to migrate the WordPress site all manually. You will need to make a dump of the database, and copy the site directory.

I preferred to use a plugin to ease the process. Many plugins are available for this purpose (i.e. http://premium.wpmudev.org/blog/8-plugins-for-safely-moving-wordpress/). I chose Duplicator.

Duplicator

I will not go into details for Duplicator use, so have a look to this tutorial if you want detailed explanations…

Basically, on the old site, you need to use the Duplicator plugin to create and download the installer.php and the archive containing all your website files and the database dump.

Then, create a folder on your new server to host the new site and change ownership. To know which user is used by Apache:

  •  and find the user that owns the process. For me it’s www-data. So replace www-data with your Apache user if different.

Push the installer.php and the archive in this directory.

Then, go to your browser, and navigate to the installer.php (http://$your_server/$newsite/installer.php) and follow instructions (pay attention to open the « advanced » options to also change the new website url). Use the MySQL database_name, username and password you used in the preparation step.

Once the process is done, remove the installation files.

Permissions

You need to manage correctly the permissions in order to not be hacked too easily! (Again, replace www-data with your Apache user if different)

To make Duplicator plugin work, I also had to set www-data ownership to the wp-snapshots folder :

WordPress upgrades and plugin installations

To not be asked about FTP information (FTP server, username, password) each time you want to install or update a plugin, or upgrade WordPress, simply add this line to your wp-config.php:

Apache configuration

Finally, you need to add a configuration for your new site in Apache.

Enable the new site:
And finally, reload Apache: