Hi,
In this post, I am explaining the steps to migrate a wordpress website from one hosting space to another.
Wordpress is a popular blogging software now adays and is used in many of the popular websites. It was completely based on mysql and php. The key configuration file for the wordpress is wp-config.php where the wordpress stores the database details.
Typical configuration details of mysql in wp-config.php is like below
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'skm_wp717');
/** MySQL database username */
define('DB_USER', 'skm_wp717');
/** MySQL database password */
define('DB_PASSWORD', 'dbpassword');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
We should specify a database with a db user with full privileges to the database. Also need to specify the database password of the DB user.
Here I only describe the steps needed to migrate the wordpress website
1)First login to your wordpress website document root(for a cpanel it will be /home/user/public_html). And open the configuration file wp-config.php. Note down the database name, username, password from it.
2)Take a backup of the database you got from the configuration file wp-config.php.
If you have root access to the server, then you can create a database backup using mysql dump
mysqldump -u root -pdbpassword skm_wp717 > skm_wp717.sql
This will generate the mysql backup in sql format.
Also you can export the backup of the database from the phpmyadmin.
3)Now you need to copy the data from the existing server to a new server. I assume you already know the document root where the database files exists for the wordpress site. So you can eithere use scp or rsync to copy the files from here to there. You can also use the FTP as well.
scp example command for the transfer
scp -r root@servername:/home/user/public_html root@remoteserver:/home/newuser/public_html
Also copy the database to the new server using scp or rsync or ftp
scp root@servername:/home/user/skm_wp717.sql root@remoteserver:/home/
4)Now the data and mysql has been migrated. You need to check if the permission for the files we transfered are correct with respect to the user in the new server. If not you need to change them manually
That is for changing the owner ship and group of the files in the new server .
cd /home/user
chown -R newuser:newuser public_html
if all the files need to have 644 permission , you can use the command find to change the permission of files to 644 and directories to 755.
Note: the below command is for cpanel users , as cpanel files need to have 644 permission for files and 755 permission for directories
cd public_html
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 { } \;
5)Now create a database (Eithere you can use the same name or another). If you have different name . then you need to change it in the wp-config.php
Also create a database user with password and grant all previlages to the user on that database.
6)Now restore the database tables from the backup sql file to the new database we had created.
mysql -u root -ppassword newdatabase < skm_wp717.sql
Once it completes you have all the database data on your new db.
7)Open wp-config.php and change the values to the new one on it. Modify database name , user and password to the new one if it is different from the old server. If you have created the db, user and password same as that of the old server, you can skipp this step, but need to cross check the wp-config.php
8)Open your website with the new configurations from the new server. You can do it by specifying the new ip with the website name in /etc/hosts file in your linux system
open /etc/hosts
ip websitename
If every thing is correct, then the wordpress page will load fine.
Cheers
Syamkumar.M
In this post, I am explaining the steps to migrate a wordpress website from one hosting space to another.
Wordpress is a popular blogging software now adays and is used in many of the popular websites. It was completely based on mysql and php. The key configuration file for the wordpress is wp-config.php where the wordpress stores the database details.
Typical configuration details of mysql in wp-config.php is like below
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'skm_wp717');
/** MySQL database username */
define('DB_USER', 'skm_wp717');
/** MySQL database password */
define('DB_PASSWORD', 'dbpassword');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
We should specify a database with a db user with full privileges to the database. Also need to specify the database password of the DB user.
Here I only describe the steps needed to migrate the wordpress website
1)First login to your wordpress website document root(for a cpanel it will be /home/user/public_html). And open the configuration file wp-config.php. Note down the database name, username, password from it.
2)Take a backup of the database you got from the configuration file wp-config.php.
If you have root access to the server, then you can create a database backup using mysql dump
mysqldump -u root -pdbpassword skm_wp717 > skm_wp717.sql
This will generate the mysql backup in sql format.
Also you can export the backup of the database from the phpmyadmin.
3)Now you need to copy the data from the existing server to a new server. I assume you already know the document root where the database files exists for the wordpress site. So you can eithere use scp or rsync to copy the files from here to there. You can also use the FTP as well.
scp example command for the transfer
scp -r root@servername:/home/user/public_html root@remoteserver:/home/newuser/public_html
Also copy the database to the new server using scp or rsync or ftp
scp root@servername:/home/user/skm_wp717.sql root@remoteserver:/home/
4)Now the data and mysql has been migrated. You need to check if the permission for the files we transfered are correct with respect to the user in the new server. If not you need to change them manually
That is for changing the owner ship and group of the files in the new server .
cd /home/user
chown -R newuser:newuser public_html
if all the files need to have 644 permission , you can use the command find to change the permission of files to 644 and directories to 755.
Note: the below command is for cpanel users , as cpanel files need to have 644 permission for files and 755 permission for directories
cd public_html
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 { } \;
5)Now create a database (Eithere you can use the same name or another). If you have different name . then you need to change it in the wp-config.php
Also create a database user with password and grant all previlages to the user on that database.
6)Now restore the database tables from the backup sql file to the new database we had created.
mysql -u root -ppassword newdatabase < skm_wp717.sql
Once it completes you have all the database data on your new db.
7)Open wp-config.php and change the values to the new one on it. Modify database name , user and password to the new one if it is different from the old server. If you have created the db, user and password same as that of the old server, you can skipp this step, but need to cross check the wp-config.php
8)Open your website with the new configurations from the new server. You can do it by specifying the new ip with the website name in /etc/hosts file in your linux system
open /etc/hosts
ip websitename
If every thing is correct, then the wordpress page will load fine.
Cheers
Syamkumar.M
No comments:
Post a Comment