How to migrate site from local development machine to live site?

How to migrate site from local development machine to live site?

Most web developers like to develop websites on local development machines and on completion migrate it to a live site. In this post, we will see how to migrate a site developed locally to a live site. In this tutorial, the local site is build using Drupal CMS (PHP, MySql) on Windows using XAMPP suite.

Check out these previous post how to install XAMPP on Windows for development purposes:
How to install and run XAMPP on Windows? (Guide)
How to install and run WordPress using XAMPP on Windows?

How to migrate site from local development machine to live site?

To run a live site, we need to have a host purchased from web hosting companies and a domain name. I will not be covering the details here.

A) Prerequisites:
1) Web Hosting is purchased
2) Domain is purchased
3) We are able to access the Control Panel on the web host (LInux Host and CPanel in this case)
4) FTP account is created
5) Download and install free FTP program such as FileZilla
(See here How to configure FTP on FileZilla client program? )

B) Preparation on the live server (host):
1) Access www.sitename.com/cpanel
2) Click on "MySql databases"
3) Create a new database

4) Create a new user for the database and set password. 
Remember to note the database name, user name and the password.
create mysql database user cpanel

5) Add / Assign the user created to the database

add assign new user to database cpanel

6) Grant "full privilege" to the user

grant full privilege to mysql user cpanel
The database and user is created. We are now ready to import the database from the local machine.

C) Export database from local machine:
1) Access localhost/phpmyadmin and login
2) Click on the database to be exported
3) In phpMyAdmin, click on the "Export" tab
4) Export the database. A .sql file will be downloaded on the local computer

export mysql database phpmyadmin localhost


D) Import the local database to live site:
1) Access www.sitename.com/cpanel
2) Click on 'phpMyAdmin"
3) Click on the database created in step "B"
4) Click on the "Import" tab
5) Browse for the .sql database file exported in step "C"
6) Wait for the process to complete

E) Upload the website files to the live server
1) Open FTP program like FileZilla (See here How to configure FTP on FileZilla client program? )
2) Connect to the live site via FileZilla
3) Upload the website files to the root of the live server.
If the site is being uploaded to a subdomain or subfolder, upload inside the respective folders.
4) Wait till all the files are uploaded.

F) Edit database details in the settings file
Usually, the name of the database, the database user name, and the password used to conenct to the database on the live site will be different from the details used on local development environment. So, depending on your kind of setup, the details need to be edited in the settings file. In this case, the website is built using Drupal, and thus, we'd be editing the "Settings.php" file.


1) Access www.sitename.com/cpanel
2) Click on File Manager
3) Navigate to “Public_html\sites\default”
4) Open "settings.php"  to edit
5) Scroll down and edit the following lines in "settings.php"
  • 'database' => 'localdbname', //enter the name of the new database
  • 'username' => 'root',//enter the username of the new user created for the database
  • 'password' => 'root', //enter the password of the new user created for the database
drupal settings php database name username password

 6) Save the "settings.php"

You can also edit the "settings.php" before uploading the site files to the live server in step "E" .

G) Testing
Open the website in a browser by it's url : www.yoursite.com and see if the site opens. If the above process was followed correctly, and the settings files is updated with the database and user details created, the site should work correctly.




Comment with Facebook

Comments