How to migrate WordPress site from localhost to server
To migrate WordPress site from local installation to a production server follow this few simple steps. We are going to show you how to do it using popular tools – phpMyAdmin and NotePad++.
1. Export database
- Navigate to phpMyAdmin (http://localhost/phpmyadmin/) in your browser
- Login to your local database
- Click Databases
- Click on your WordPress database name
- Click Export
- Leave Quick option
- Click Go button
- Save your sql dump file on your drive
2. Replace service URL
You need to change your url address from http://localhost/ or http://localhost/wordpress/ or something similar to your production URL – http://www.yoursite.com/
- Open sql dump file which you created in step 1 with NotePad++
- Push Ctrl+H on your keyboard – this will start Replace dialog
- In the Find what input field enter your local URL which is going to be something like http://localhost/ or http://localhost/wordpress/
- In the Replace with input field enter your WordPress production URL like http://www.yoursite.com/
- Pay attention to the last slash ‘/’ sign to replace URL in the correct way
- Click Replace All
3. Replace installation path (optional)
//Since there are plugins and themes out there that use wordpress installation path you might need to perform this step.
Perform step 2 to replace files installation path with the one that matches your production site wordpress folder. Remember to use full path.
For example replace C:\Development\wamp\www\wordpress with /home/users/yoursite/public_html/wordpress.
4. Import database
- Navigate to phpMyAdmin which controls your production database server
- Click Databases
- Provide your database name
- Provide encoding
- Click Create
- Click on newly created database
- Click Import
- Click Browse and navigate to Your modified sql dump file
- Click Go
5. Modify wp-config.php file
- Modify wp-config.php file to match your needs
define('DB_NAME', '[PRODUCTION_DATABASENAME_HERE]'); define('DB_USER', '[PRODUCTION_USERNAME_HERE]'); define('DB_PASSWORD', '[PRODUCTION_PASSWORD_HERE]'); define('DB_HOST', '[PRODUCTION_HOSTNAME_HERE]');
6. Upload instance code to server
Upload Your local WordPress files to the server to the installation directory which you have set in the step 3.