Server Operating System : Any operating system available
WordPress Version : 4.5
Webserver Engine : Any Webserver engine will be fine as long as it supports PHP for server-side scripting.
Migrating WordPress-based Website
If you want to migrate your website which is based on WordPress platform from one host to another or even from your local PC to your hosted server, there are steps which is needed to be done before your WordPress based installation website can be viewed normally. The steps are detailed below :
- First of all, copy all of the source code of your website in your target location. It can be a PC, laptop or even your own personal server. Be sure that you have already setup your own Web Server such as Apache Web Server, Microsoft IIS or even any utilities available as a package of Web Server, Database Server, etc such as XAMPP.
- Restore your WordPress-based website database to your target location. If you set up your own Website, you also need to pay attention to your Database Server. You need a Database Server to be able to restore the database of your WordPress-based website. In this article I am doing it by accessing MySQL command line as shown as follows :
user@hostname:~$ mysql –uroot dbname < dump_dbname_file.sql
- Login to your MySQL database, in this article I am using MySQL console to manipulate the already restored WordPress-based website database with the following command :
user@hostname: ~$ mysql mysql –udb_login_username –p
- Update few entries in the database. Supposed you are using some SQL Editor or even PHPMyadmin which is surely going to help you a lot, please feel free to use it. In this article, I am just going to use a traditional command-line and execute some queries.
- Access any tools which is best for you to manipulate WordPress database as follows :
mysql> UPDATE wp_posts SET guid = replace(guid, 'http://old-url.com','http://new-url.com'); Query OK, xxxx rows affected (x,xx sec) Rows matched: xxxx Changed: xxxx Warnings: 0 mysql> UPDATE wp_posts SET post_content = replace(post_content, 'http://old-url.com','http://new-url.com'); Query OK, 56 rows affected (x,xx sec) Rows matched: xxxx Changed: xx Warnings: 0
One of the most important table in WordPress platform is wp_posts. It stores data such as Pages and also navigation menu items from among of them.
mysql> UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://old-url.com','http://new-url.com'); Query OK, 55 rows affected (x,xx sec) Rows matched: xxxxx Changed: xx Warnings: 0
The other is shown above is wp_postmeta. It is also need to be updated.
mysql> UPDATE wp_options SET option_value = replace(option_value, 'http://old-url.com','http://new-url.com') WHERE option_name = 'home' OR option_name = 'siteurl'; Query OK, 2 rows affected (0,01 sec) Rows matched: 2 Changed: 2 Warnings: 0
The last table is wp_options.
The main purpose of the above step by updating database records is to modify the permalink used in the WordPress-based website. We may have different URL address from the source location with the target one. So, we have to change the old URL which is the URL of the source location to the new URL and it is the destination location of the WordPress-based website we are going to restore.
- The last thing is to configure and edit wp-config.php exist in the WordPress-based source code. It is done to make the new WordPress-based source code can be executed by connecting to the MySQL database exist in the destination location. As we already know, we have already created another database in the destination target so that the WordPress-based source code which has already been copied can connect to the database. But in order for the WordPress-based source code successfully connect to the database, it need a little configuration to the database connection configuration script. It is located in the root folder of WordPress-based source code called wp-config.php. Below is the snippet code which has to be changed :
/** The name of the database for WordPress */ define('DB_NAME', 'nama_db'); /** MySQL database username */ define('DB_USER', 'nama_db_user'); /** MySQL database password */ define('DB_PASSWORD', 'password'); /** MySQL hostname */ define('DB_HOST', 'localhost');
It need to be changed based on the connection used to connect to the destination’s MySQL database so that the source code can be used to execute and connect to the it properly.
- Last but not least, it need to be tested. After successfully configuring and finishing all the steps, try to access the new URL of WordPress-based website in the browser.