Migrate local WordPress installation to web server

Have you created a great website or blog locally with WordPress under XAMPP and now want to transfer it to a real web space? A few steps are necessary for this. In this guide I will show you how to migrate a local WordPress installation to a web server.

foreword

There are different ways to migrate a local installation to a web host. You can migrate the website manually or use plugins to do so. I prefer the manual way here because I can better control what has been changed. The way shown here has always worked best for me. I only use a plugin to automatically replace the paths in the database.

requirements

First of all you need a web server including a domain. You have to book this in advance with a provider. Common providers in Germany are, for example, Strato, 1&1 or AllInkl.

If you have booked the web hosting with the provider, you will of course need admin access to this. You also need FTP access to your web space and access to the MySQL database management phpmyadmin.

Locally on the PC you need admin access to your WordPress installation and also access to phpmyadmin. You can find out how to get there in the “Install WordPress locally with XAMPP” guide.

Find WordPress absolute server paths

In order to be able to replace certain paths in the migrated database later, you need the absolute server paths of your WordPress installation. The easiest way to do this is with a PHP file (here: path.php) with the following content:

$p = getcwd ();
echo $p;
?>

Now put this file in the root directory of your website. With your local installation, you will usually find the root directory under C:xampphtdocs. In some cases also in a subfolder of htdocs. The directory can also have a different name on the web space. You have to save the file there using an FTP program. You can use FileZilla for this, for example.

Then you open the file with a browser. This would be local http://localhost/path.php and on the web space http://eureDomain.de/pfad.php.

Find WordPress path

It is best to copy the output paths into a text file, as we will need them again later.

WordPress paths for migration

Install the WP Migrate DB plugin

Install the WP Migrate DB plugin in your local installation. You can download the plugin here: https://de.wordpress.org/plugins/wp-migrate-db/

We will need this plugin later to have the paths in the database replaced. The advantage of the plugin is that it can also adapt so-called serialized data and thus problems with the migration can be avoided. More information about WordPress Serialized Data can be found here: https://wpengine.com/support/wordpress-serialized-data/

You don’t have to set anything in the plugin at first. The pure installation is sufficient.

Export local database

This step is about exporting your local MySQL database. To do this, go to http://localhost/phpmyadmin in your browser. The database management of your local XAMPP installation opens.

In the left area you then click on your WordPress database, which you created when installing WordPress with XAMPP. You will then find the point at the top of the tabs Export.

Export WordPress database

The wizard for exporting the database opens. As export method you select “fast” and for format “SQL“. After clicking OK the database is downloaded. You will then find the database file with the file extension .sql in your download folder. We need this file in the next steps.

Export database phpmyadmin

Create a new database on the web server

In this step, create a new empty database on your web space. Depending on the hosting environment, you must also create a corresponding database user who has access to the database. You also note this data in the text file

Lenovo (17.3 inch) HD+ Notebook (Intel Core i5 1035G1 8-Thread CPU 3.60 GHz, 8GB DDR4, 512 GB SSD, Intel UHD, HDMI, Webcam, Bluetooth, USB 3.0, WLAN, Windows 10 Prof. 64 Bit) # 6724

Lenovo (17.3 inch) HD+ Notebook (Intel Core i5 1035G1 8-Thread CPU 3.60 GHz, 8GB DDR4, 512 GB SSD, Intel UHD, HDMI, Webcam, Bluetooth, USB 3.0, WLAN, Windows 10 Prof. 64 Bit) # 6724*

Last updated on 01/23/2022 / Affiliate links / Images from the Amazon Product Advertising API – As an Amazon Associate, I earn from qualifying purchases.

Upload local WordPress files

In the next step you have to upload the complete local WordPress directory to your provider. You do this again via FTP with the program FileZilla. Make sure that you upload the files to the correct directory. In hosting environments with multiple domains, you may have to upload the files to a subfolder. The best way to find out is in the domain settings. In some cases, FileZilla may not be able to transfer all files. In this case, you must add the failed files to the queue again and then let them process again.

WordPress directory with files

Import database to provider

Now look for the item databases in the administration area of ​​your web space. There you should be able to access the database management phpmyadmin. This should look similar to the local version of phpmyadmin.

On the left-hand side you now select the newly created database and then click on in the menu Import.

In the import window, you now select the previously downloaded SQL file at the top. The rest of the settings can be left at the default settings at this point.

Migrate WordPress database

Depending on the hosting provider, there is also the option of importing a database outside of phpmyadmin. You should also note that many providers limit the maximum upload size for SQL files. Then the database file must be split beforehand. With SQL Dump Splitter, this works relatively quickly and easily.

Adjust the wp-config.php file

When all files have been uploaded, you have to download the file wp-config.php adjust. You can find the file in the main WordPress directory. You can also edit the file via FileZilla by using Right click – Edit click on the file.

In this PHP file you must now adjust the path for your WordPress installation and enter the access data for the new MySQL database.

define( ‘DB_NAME’, ‘wptest’ );
define( ‘DB_USER’, ‘root’ );
define( ‘DB_PASSWORD’, ‘yourpassword’ );
define( ‘DB_HOST’, ‘localhost’ );

define( ‘WP_SITEURL’, ‘https://yourDomain.de’ );
define( ‘WP_HOME’, ‘https://yourDomain.de’ );

Customize and replace WordPress paths

In the penultimate step, the database must now be adjusted. You should now be able to access the WordPress admin panel under the new domain. You can find that under https://yourdomain.de/wp-admin. The access data are the same as for your local installation.

Now check first in the left menu below Settings – General whether the paths for the new domain match.

Then click in the WordPress menu Tools – Migrate DB to start the previously installed plugin. With the help of the plugin, the old paths can now be searched for in the database and replaced with the new paths.

Now click on the overview page of the plugin migrate and then choose Search & Replace.

Adjust WordPress paths after migration

In the settings and paths you should proceed very carefully, because errors at this point later affect the function of the website.

Migrate WordPress web server Adjust paths

Also note that you accessed the site locally in XAMPP via http. You probably want to change all links to https in the online version in order to be able to use an encrypted connection. In addition, an SSL certificate must be installed on the web space. Depending on the provider, the free service Let’s Encrypt can be used here, for example.

Set up forwarding for HTTPS

This step is optional and depends on whether you want to use an encrypted connection via HTTPS on the new website. You also need an active SSL certificate on your web space. Did you already replace HTTP with HTTPS in the path replacement step and also in the wp-config.php given the appropriate paths, the bulk of the work for this step is already done. In addition, you should in the root directory of your WordPress installation the file .htaccess add the following information below #END WordPress:

#END WordPress

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

Check website for functionality

After you have transferred all data and adjusted the paths in the config files and in the database, you should Check website for functionality. To make sure that all paths have been correctly replaced, you first check the internal linking structure and then the functionality of plugins such as the contact form.

Conclusion

The manual WordPress migration is a bit more complex than a migration using a plugin, but it also offers the possibility for individual adjustments. You can also intervene manually in the event of an error and thus have a better overview of the individual steps.

Last updated on 01/23/2022 / Affiliate links / Images from the Amazon Product Advertising API – As an Amazon Associate, I earn from qualifying purchases.