Web development can always take a lot of time. With a localhost software like WAMP (in Windows) or MAMP (in Mac) installed in your computer, you can speed up your web development process.
After completing your development, and applying all the required tweaks, it’s time to share the work with the world out there. You can now move your website to a live site from your localhost.
Let us discuss two methods to move your WordPress website from
localhost to your live website. You can read both and choose the best method that suits you.
- Move your WordPress to a live site with the help of a plugin
- Move your WordPress manually into your live site
Things You Will Need To Begin
Before migrating to a live server, you need to ensure that you are ready with certain things in your hand.
Seemingly, you already have a WordPress installed and running on your localhost. You also have full access to this WordPress site.
Now, for creating a live site, you need a domain name and a web hosting (we recommend a WordPress Managed Hosting).
Last but not least, you’ll need an FTP program to upload your website content to the live site.
With all these in hand, let’s move on to migrating the WordPress website.
Transfer Using Built-in WordPress Tools
Suppose that you only need to transfer posts, pages, media, etc. In such a case, what you need is a mechanism to move just these to the live site. Fortunately, tools for these are already baked into the WordPress settings. For a start, install a fresh WordPress in your live site’s server. If you are subscribing a WordPress hosting, the provider will offer you with a one-click install. Anyway, it’s easy to do the install manually too.
After installing WordPress, log into your localhost, navigate to Tools, and select Export.
Select the ‘All content’ radio button and press the Download Export File button. An XML file with complete website content will be downloaded.
Once this is done, go to the live site, navigate to Tools, and select Import. When prompted to choose where to import from, go for WordPress. Now, Install and activate the WordPress importer plugin.
In the importer, browse for the downloaded XML file and import it.
Now, all your localhost website data such as posts, pages, media, custom fields, etc. will be imported to your live site.
What’s remaining for you to do is install the themes, required plugins, widgets, and all other site elements, so that the live site looks the same as your localhost.
When it seems to be pretty easy to export and import with the built-in settings, frequent use of this function may take a lot of your time. So, it is rather easy-in-effect to create a complete copy of the localhost website on the live site.
Let’s see how to do that.
Manually Transferring WordPress From Local To Live Site
Manually transferring the WordPress site is something which works when the plugin transfer method does not work. It’s also a good choice if you are the one who wants to do it your way.
Export the Local WordPress Database
The first thing you need to do is export your local WordPress database. We’ll be using phpMyAdmin to do that. If you are unfamiliar with it, then you might want to take a look at our guide to WordPress database management using phpMyAdmin.
First, you have to export the local WordPress database. You can use phpMyAdmin for this. Just navigate to http://localhost/phpmyadmin/ and select your WordPress database. Now from the top menu bar, click Export.
You can either choose ‘Quick’ or ‘Custom’ in the Export method option. Custom provides more options in exporting the database. However, let’s go with Quick. After choosing Quick, press the Go button to download your WordPress database.
Upload the WordPress Files to the Live Site
Now it’s time to move your website files to the live domain.
Open the FTP client and connect with your web hosting account. After connecting to the live site, be sure to upload the files in the right directory. Say, if you want to host your site on xyz.com, you need to upload all your files into the public_html directory.
Next, select the local WordPress files and upload the files to the live server.
Creating MySQL Database on the Live Site
The same time your FTP client is uploading the files, start importing the database to your live server. As cPanel is used to manage accounts by most hosting providers, you can use cPanel to create a database.
As a first step, log into the cPanel dashboard. In the databases section, select ‘MySQL Databases’.
On the upcoming screen, enter a name for the database and click on ‘Create Database’.
Now, scroll down and create/add an existing user to the database from the MySQL Users section.
Once the user is added, set MySQL privileges for that user. Grant all the necessary privileges making sure that every checkbox is ticked, and click on Make Changes.
Importing WordPress Database on Live Site
Now you have to import your WordPress database.
From your cPanel dashboard, go to the databases section and select phpMyAdmin.
From phpMyAdmin, select the database you had created in the recent step. phpMyAdmin will now display your database without any tables.
From the Import tab, click the choose file button and select the database you had saved in the first step.
Finally, click on ‘Go’ at the bottom. phpMyAdmin will now start importing the database.
Changing the Site URL
Now, change the website URL in your database so as to connect with the live WordPress website.
Open phpMyAdmin and search for the wp_options table in the database that you had just imported. If you had opted to change the prefix of your database, then the table name will be [prefix]_options.
To open the page with the list of fields inside the wp_options table, click on Browse.
Under options_name, look for the siteurl. Click on Edit Field icon at the far left end at the beginning of the row.
Click on the edit field to open an edit field window. You will see your localhost URL as the option_value. Replace this with the new live site URL. Save the changes clicking on the Go button.
Now, you should replicate this step for option name – home. Since the wp_options page is a few pages long, just find the home tab. Generally, the home will be on the second page. You’ll just have to navigate there with the pagination arrows.
Update the home URL to match your siteurl.
Setting Up Your Live Site
After importing the database all other contents, now let’s configure WordPress.
Just load the website to find an Error Establishing Database Connection error.
To solve this, connect to the website with FTP and edit the wp-config.php file. After editing and saving wp-config.php, upload it again to the server.
Your WordPress website should be live now.
Now, log into your WordPress admin dashboard, go to Settings and then General. Just scroll down and Save the Changes. This is to make sure that the website URL is aligned wherever necessary.
Then, go to Permalink from Settings and Save Changes to ensure proper working of all post links.
Fixing Images and Broken Links
Whenever you move a WordPress website from one to another domain, or from localhost to a domain, there will be issues with broken links and images missing.
You can solve this issue with a simple SQL query:
|1||UPDATE wp_posts SET post_content = REPLACE(post_content, ‘localhost/test/’, ‘www.xyzsite.com/’);|
Navigate to phpMyAdmin, click on your database, and then on SQL from the top menu. Write down this query in SQL, and remember to change it with your own localhost and live website URLs.
Now, you’ve successfully completed the migration of your WordPress from localhost to the live site.
Transferring WordPress Using a Migration Plugin
This is an easier method which even beginners will find easy. We can use a migration plugin in WordPress named ‘Duplicator’ for moving to a live site.
Setting Up Duplicator
As you will be familiar with installing a WordPress plugin, go on and install the ‘Duplicator’ plugin. After installing and activating, navigate to Duplicator » Packages and click on Create New.
Now click the ‘Next’ button to continue. The plugin will now run some tests to check for the proper working of things. If everything is marked Good, you can proceed to click on the Build button.
The building process takes a few minutes based on the size of the website. Take care not to leave the tab until the process is finished.
Now, as the process is complete, press the One Click Download button and download both the files into your computer.
Out of the two files, the archive file is a copy of your whole WordPress site. It includes core WordPress files and also the images, uploaded content, plugins, themes, and a backup of the WordPress database. The installer file is a script and automates the migration process unpacking the archive file.
Creating a Database For The Live Site
The first step before uploading WordPress to your hosting server is to create a MySQL database for your live site. If the MySQL database is already created, skip this step.
For creating the MySQL database, visit the cPanel dashboard of your hosting account. From the Databases section, select MySQL Databases icon.
When you see the field to create a new database, provide a name for the database, and click ‘Create Database’.
A new database will now be created in the cPanel. Now, scroll down to MySQL Users section. Create a username and password for the new user and click ‘Create a user’.
Go on to provide permissions for the new user. Scroll down to find ‘Add User to Database’. Select the database user you recently created, select the database, and click the ‘Add’ button.
Now your database is ready to use. Always make a record of your database name and credentials. These will be needed in the next step.
Uploading Files to the Live Site
The next step is to upload both files (archive and installer) from localhost to the hosting account.
Connect to the live site with an FTP client. Self assure that the website’s root directory is empty. The root directory is normally /home/public_html/ folder.
Some hosting companies have WordPress already installed in the server. If so, you need to delete those files. Then you can upload the archive and installer files to the root directory.
Running The Migration Script
After uploading the migration files, visit the following URL:
http://xyz.com/installer.php (Just replace xyz with your domain name)
This launches the Duplicator migration wizard.
The installer automatically scans to find the archive file and then runs a validation test. Now, check the terms and conditions checkbox before continuing to the Next button.
On the coming screen, enter your WordPress database information when prompted.
Most likely, you will have localhost as your host. Then, input the database details (of which you created in the previous step).
Now click Next to continue. The Duplicator plugin will now import the WordPress database backup from the archive into the new database.
You will now update the site URL when prompted. You won’t have to do this manually, as the plugin has auto-detection of the URL and its path.
Click Next to continue. The plugin will now complete the migration process and will take you to a success screen. Click on the Admin Login button and go to the admin area of your live WordPress website.
After you log in, Duplicator will clean up the installation files automatically.
Now, you’ve moved your WordPress successfully!
We really hope we helped you out! Wish to help us back? Just share your thoughts and concerns with us in the comment box. Sharing is the best caring. 🙂