It is the best way to develop WordPress website in your local server (using software like WAMP & MAMP) and move it to the live server. You can develop the website in the live server but please try to avoid developing in live server. Because in starting days I had the habit of developing the website in live server. One day my server was crashed and all data were lost, I didn’t have the backup. So I was suffered and rebuild the site. Also, the server will take high bandwidth when you are working on it and may slow down the development process. So have the habit of developing the website in your local server and move WordPress website from local server to live server.
Now I assume you have completed the WordPress website development in the local server and ready to move it to live server. Before that, I want to confirm you have the hosting details (access to file manager and database)
There are two methods available to move WordPress website from the local server to the live server. Are you ready to go?
Method 1: Export content using built-in WordPress tools
In this method, you are going to export the content (posts, pages, comments etc,) using the WordPress export tool. The exported file will be in the XML format.
1. Export Content
To export the content you need to go to TOOLS -> EXPORT in the admin left menu section. There you can select which content needs to export whether post, page or comments. You can also export all the content. Please see the above the image for reference.
You have the content of the website in your hand. Now you are going to import the content in the live site. Before that, install and activate your developed/customized theme in the live site. Then go to TOOLS ->IMPORT and install the WordPress importer. Now it installed then browses your XML file and import it. See the below image for reference.
Now your content is moved to the live server successfully. But in this method, you need to rebuild your menus and widget. This is one of the methods to move your content to live quickly. But I do not recommend this method to move the whole site to the live site, because you have to work on it once again.
Method 2: Moving all files and DB from localhost to live server.
This is the efficient and easily doable method. In this method, you only need to do seven steps and it will not take much time.
- Export the database SQL file from localhost
- Create a new database in the live server
- Import the SQL file into a new database
- Move all files from local to live server
- Edit the wp-config.php file
- Modify permalinks
- Fix the image path and broken links
1. Export the database SQL file from localhost:
In your localhost go to phpmyadmin (http://localhost/phpmyadmin) and select your WordPress database. In the top menu, you can see the Export option, click on that. The export page will open (see below image for ref.), in that you need to select SQL format and press the Go button. Your SQL file is now exported.
2. Create a new database in the live server:
Login into your hosting account, in the control panel (CPanel) you can see “MySQL Database”. Click on the MySQL Database, a page will open with the form to create Database and DB user. Please see below images for reference (it may vary depending upon the control panel)
3. Import the SQL file into a new database:
Like you export the database from the local server you are going to import it into the live server. Go to the live server phpmyadmin through CPanel and select your database which you are created. In the top menu, you can see the import option click on that. The import page will open (see below image for ref.), in that page, you have an option to browse SQL file. So here choose your exported SQL file from your computer and press the Go button. Your SQL file is now imported.
In the imported database you need to change the site URL because in the local server the URL should be like http://localhost/sitename. You need to change it to your live site URL. To do this, go to “wp_options” and update ‘siteurl’ and ‘home’ with your live site URL.
4. Move all files from local to live server:
You have successfully moved the database to the live server. Now it is the time to move all files from the local server to the live server. You can do it using FTP (Filezilla or Fireftp) or through File Manager (It is the easiest and best way). Move it wherever you want like in the root (public_html or www) or in the subfolder.
5. Edit the wp-config.php file:
After moving all files from the local server to the live server, you have to edit the wp-config.php file and update the old database connection with the new database connection.
define(‘DB_NAME’, ‘Database name’);
define(‘DB_USER’, ‘Database username’);
define(‘DB_PASSWORD’, ‘Database Password’);
6. Modify the Permalinks:
After completing all the above steps, you can access the admin page. So login into your admin page and change your permalinks by going to Setting -> Permalinks. Please see the below image for reference.
7.Fix the image path and broken links
Now your site is almost ready and the final step is to fix the image path & inner links path. During developing in the local server, the URL path is created as like http://localhost/yourlocalsite. So, you need to update this URL path with your live website URL path.
This can be done in the database. Please go to your database and click SQL which is in the top menu and run the below SQL Query,
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/localsiteurl/', 'www.livesiteurl.com/');
(Note: Replace localsiteurl and livesiteurl with your URLs)
Yes, you have done it. Now you can able to access your new live website. Please take regular backup of your website. If you have any feedback or question please drop it in the below comment section. If you find this post useful please share it with your friends.