Numerous plugins are available on wordpress.Org is offered to make backups of a WordPress installation and then transfer them to another server if desired. However, a manual cloning is also done quickly. There are at least two possible ways to do this, a simple one and a better one. And then there's the simple best.
Easy way: move WordPress with your own on-board tools
WordPress itself offers an export and import function, with the help of which the contents of a WordPress installation, for example the local test version or development environment, can be transferred to another one. The procedure is basically self-explanatory. In my tests, however, the import of attachments (images) did not work, so here is a workaround, which also has the advantage that internal links from one post to another work as expected after the server change:
- In the WP backend of the local resp. Source installation under Tools -> Export Data to save "All Content" in a WXR file (WordPress eXtended RSS) on disk. It will be installed there in the form name.Wordpress.Date.Xml stored.
- Open this file with a text editor and search&replace all internal references of the kind http://localhost/ wordpress1 or http:// www.Sourcedomain.De search and through http:// www.Targetdomain.Replace de; then save.
- Go to the backend of the target installation, select the menu item "Import data", choose "WordPress" as the format, and, if necessary, click "OK". First install the then offered plugin. Then select the XML file you just created from your hard disk and import it (do not select "Import Attachments" for this workaround). If the authors of the original installation are not yet created, the import script does this automatically. An assignment of the contributions and pages to already existing authors is also possible over the offered selection fields.
- Finally, transfer all contents of the source installation in the folder wp-content/uploads to the corresponding folder of the target installation using an FTP program.
After that all posts, pages, comments, custom fields, categories, tags, custom content types and also images, videos, sounds should have arrived in the target installation. Also possibly. Self created navigation menus will be imported (but not activated), but if imported multiple times, the single menu items will be stupidly multiplied.
This simple transfer method requires WordPress to be installed on the target server. Posts and pages that already exist on the target WordPress will not be overwritten. The import with the WP on-board tools is therefore basically only suitable for a one-time transfer. Revisions, for example, of posts on localhost and subsequent re-transfer to the live server are not possible so. Plugins, themes as well as configurations for example of widgets, menus, settings of the points permalinks, discussion, media, etc. Are not transferred. With the following described kind however with only small additional expenditure an almost identical WordPress image is produced.
Better option: Clone WordPress with phpMyAdmin and SQL
A note in advance: On the net you can find numerous instructions of the procedure described below. Some of them though, z. B. The step-by-step instructions for transferring WordPress from a local server to a domain by Elmastudio, which are well positioned on Google and therefore highly regarded, make a mistake: They do not take into account that WordPress stores a lot in the database in the form of so-called serialized data. The consequence is that configurations of plugins, widgets, menus etc. Will not work. Cannot be read out by WordPress after the database has been installed. Background images in the header are no longer visible, user-defined menus have to be reassigned to their desired positions, text fields in widgets have completely disappeared. The following instructions provide for a WordPress move without rework (but also: without guarantee), but at first glance seems a bit more cumbersome for it.
Export database. In contrast to the above procedure, this export is executed directly within the database application or. For example with the help of the database administration interface phpMyAdmin. Phpmyadmin is accessed with an internet browser. For a local installation using the Uniform Server the URL is http://localhost/us_phpmyadmin/, for XAMPP it is http://localhost/phpmyadmin/. For online installations it depends on the provider, at all-inkl.Com, for example, the address is http:// www.Yourdomain.En /mysqladmin/
There might be a small catch though: text fields within widgets are not affected by the URL changes. These texts, which also contain HTML links e. B. In the form http://localhost/. Are written to the widget_text field in the wp_options table as serialized data. Therefore, references to the source installation cannot be rewritten to the target installation without destroying the serialized form. The same applies to some themes for background images.
Recommended option: serialized database dump with Migrate DB plugin
In contrast to the manual method just described, the Migrate DB plugin takes care of a complete replacement of the URL. If necessary, the plugin recalculates affected serialized-data records to preserve their validity. In addition, any file paths stored in the database are adjusted (such paths are rarely used, however). For moving a WordPress installation from localhost to a live server or even from one server to another the free version is sufficient.
- Install and activate plugin on source WordPress.
- In the backend under Tools -> Migrate DB call the plugin and fill in the fields according to your own WP installation. (Small trick to find out the target path: If WordPress is already installed on the target server, simply install the plugin there as well, and then read the "file path" in the activated plugin. Or simply ask the hoster.)
- Click on "Export Database. The generated file is usually saved in the download folder of the browser.
- Use phpMyAdmin to access the database on the target server, if it already exists, or create a new one. Import the file generated by the plugin (see above under: 2. Create new database and 3. Import data). If you already have a database, the import script will completely delete the WordPress tables before importing the new data!
- Finally copy WordPress files to the target server (see above, point 5) and, if necessary. Wp-config.Php and .Adjust htaccess (see above, point 6).
Addendum: Here is an actual screenshot of the plugin WP Migrate DB, which has been modified a bit in the meantime. The transfer protocol (http:) does not have to be specified now, which is useful if http: and https: are used mixedly.