Would you like to transfer the WordPress site from a localhost to a functional website?
Working on your website privately is frequently done by installing WordPress on a local server. When you’re ready to make it accessible to online users, you’ll need to transfer it to a live server.
This article will walk you through transferring a WordPress site from localhost to a live website.
The purpose of moving the WordPress site from localhost (on your PC) to a live site
It’s safe to test website changes on a local server while keeping visitors anonymous when building your WordPress blog.
The next step is to switch from your local server to a live site once you’ve finished perfecting your website.
Let me demonstrate two methods for transferring your website from a localhost (on your PC) to a live one.
It’s advised for beginners to start with the first method, which uses a WordPress migration plugin.
The second technique demonstrates how to manually transfer a WordPress site from a localhost (on your PC) to a functional website.
You can select the approach that suits you the best:
- Method 1: Employ a plugin to transfer WordPress from a localhost (on your PC) to a live site.
- Method 2. Manually move WordPress from a localhost (on your PC) to an active website
Before moving your WordPress website
You need a few things to move WordPress from a localhost (on your PC) to a live server.
Initially, we’re assuming you have complete access to a WordPress site running on your computer on a local server (also known as localhost).
A domain name and web hosting are the following two things you’ll need.
To decide what domain and web hosting you need, use our guide on the top 5 web hosting.
Follow our step-by-step instructions on creating a WordPress website if you need help setting up your website.
Finally, you’ll need an FTP program and some FTP knowledge to upload your localhost site (on your PC) to the live site.
Ready? Let’s begin migrating your WordPress site.
Method 1: Using a migration plugin, move WordPress from a localhost (on your PC) to a live site
We advise beginners to start with this approach because it is more straightforward. WordPress will be transferred from localhost to a live site using a WordPress migration plugin.
Step 1: Install and configure the Duplicator plugin.
Setting up the Duplicator plugin on your local site is the first thing you need to do. For more information, see our step-by-step tutorial on installing a WordPress plugin.
Immediately after activation, you must visit the Duplicator » Packages page and select the “Create New” button.
Your backup can now be given a name on the screen that is brought up.
Next, press the “Next” button.
Duplicator will perform some tests to check if everything is in working order.
If everything is marked “Good,” select “Build” from the menu.
This procedure could take a couple of minutes, depending on the size of your website. Until the process is finished, you must keep this tab open.
After that, download options for the “Installer” and “Archive” packages will be available. The ‘One-Click Download’ link must be clicked to download both files to your computer.
The “Archive” file contains an exact duplicate of your WordPress website. In addition to images, uploads, themes, and plugins, it also includes a backup of your WordPress database and all the core files for WordPress.
The ” Installer ” file is a script that automatically backs up the archive file containing your website and the entire migration process.
Step 2: Establish a Database for Your Live WordPress Site
You will first have to create a MySQL database for the new live site before you can run the installer or upload the WordPress site from localhost to your hosting server.
This step can be skipped if a MySQL database has already been created.
You must go to the cPanel dashboard of your hosting account to create a database. Select the “MySQL Database Wizard” icon once you’ve found the “Databases” section.
A field to create a new database is present on the following screen.
Give your database a name, then click the “Create Database” button.
A new database will now be created for you by cPanel.
Before clicking the “Create User” button, the next step is to create a username and password for the new user.
The newly created user needs to be added to the database after that.
First, select the checkbox next to “All Privileges.”
Then, to save your changes, scroll down and click the “Make Changes” button.
Now that it’s ready, your database can be used with your WordPress website. This knowledge will be required in the following action. Ensure to note down the database name, username, and password.
Step 3. Upload the files from the local server to the live WordPress website.
The installer and archive files from your local website must now be uploaded to your hosting account.
To begin, use an FTP client to connect to your live site. Once connected, ensure that your website’s root directory is empty.
The root directory is typically the /home/public_html/ folder.
Some WordPress hosting companies will install WordPress for you when you sign up. If WordPress files exist there, you need to delete them.
After that, copy the installer.php and the archive.zip files from Duplicator to your empty root directory.
Step 4: Execute The Migration Script
After you’ve uploaded the migration files, open your browser and navigate to the following address:
http://example.com/installer.php
Remember to replace ‘example.com’ with your domain name.
This will start the Duplicator migration wizard.
The installer will perform a few tests before starting the script.
You will be told to enter your MySQL host username, password, and database name in the Setup section.
Your host is most likely going to be localhost. Following that, enter the details of the database just created in the previous step.
Then click the ‘Validate’ button to ensure the information you entered is correct.
Then, to proceed, click the ‘Next’ button.
The Duplicator will import your WordPress database’s archived backup into your new database.
It will also redirect URLs pointing to your localhost site to your new live site.
To access the WordPress admin section of your website, click the ‘Admin Login’ button now.
Logging into your live site afterward will cause Duplicator to clear the installation files automatically.
You’ve successfully moved WordPress from localhost (on your PC) to your live site; that’s all there is to it.
Method 2: Manually Move WordPress from the Local Server to the Live Site
This method will show you how to move WordPress from localhost (on your PC) to your live site. It will be helpful if the first method fails or you prefer to do it manually.
Step 1: Export the WordPress database from your local computer.
The first thing you should do is export your local WordPress database. That will be done with phpMyAdmin.
Navigate to http://localhost/phpmyadmin/ and select your WordPress database. Then, select the ‘Export’ option from the top menu bar.
You can select ‘Quick’ or ‘Custom’ for the ‘Export method:’ option. Custom gives you more options for exporting your database.
However, we recommend selecting ‘Quick’ and then clicking the ‘Go’ button to download your database.
Step 2: Copy the WordPress files to the live site.
We’ll now need to transfer your website’s files to the live site.
First, open your FTP client and connect your web hosting account. Once connected to your live site, ensure the files are uploaded to the correct directory.
For instance, if you want the site hosted on ‘example.com,’ you should upload all the files in the public_html directory.
Select all your local WordPress files and upload them to your new live server.
Step 3: Set Up a MySQL Database on Your Live Website
Your database import can begin while your WordPress files are uploaded via your FTP client to the live server.
Because most WordPress hosting providers provide cPanel to manage your hosting account, we’ll walk you through creating a database with cPanel.
The MySQL Database Wizard can be accessed from the “Databases” section of your cPanel dashboard.
You can create a new database on the next screen.
You must give your database a name before clicking the ‘Create Database’ button.
Your cPanel will now create a new database for you automatically.
After that, enter a password and username for your new user and click ‘Create User.’
Following that, you must add the newly created user to the database.
To begin, select the ‘All Privileges’ checkbox.
Save your changes by scrolling down and clicking Save Changes.
You’ve just finished establishing a new database for your live WordPress website.
Step 4: Import the WordPress database into the live site.
Importing your WordPress database is the next step.
Go to the “Databases” section of your cPanel dashboard, scroll down, and choose “phpMyAdmin.”
After being redirected there, you should then choose the database you created above in phpMyAdmin. In PhpMyAdmin, your new database will be shown without any tables.
Then choose “Import” from the top menu. Click the “Choose File” button on the import page, then select the database file from your local site that you saved in the previous step.
After that, at the bottom of the page, click the ‘Go’ button. Your database will be automatically imported into phpMyadmin.
Step 5: Modify the Website URL
You must now update the URL in your database so it can connect to your live WordPress site.
Look for the wp_options table in the database you just imported above in phpMyAdmin.
If you changed your database prefix, you might see new_prefix_options instead of wp_options.
Then, next to wp_options, click the ‘Browse’ button. Alternatively, click the link in the sidebar to open a page containing a list of fields from the wp_options table.
The site URL option should then be found in the options_name column.
Then, select the ‘Edit’ option.
This opens a window in which you can modify the field.
The URL of your local installation, which will be something like http://localhost/test, will be displayed in the option_value input box.
In this field, enter the URL of your new site, for example, https://www.hubtolearn.com.
Then, by clicking the ‘Go’ button, you can save the field.
Then, for the home option name, repeat the previous steps. There may be several pages in the wp_options menu. The second page is usually where you’ll find the home option.
Then, change the home URL to match the URL of your live site.
Step 6: Setup Your Live Site
It’s time to configure WordPress now that you’ve imported the database and uploaded your content.
At this point, your website should display an ‘Error establishing a database connection’ error.
To fix it, open the wp-config.php file on your website using an FTP client after connecting to it.
These are the lines of code you need to search for:
// ** MySQL settings - This info can be gotten from your web host ** // /** Database name for WordPress */ define( 'DB_NAME', 'database_name_here' ); /** MySQL database username */ define( 'DB_USER', 'username_here' ); /** MySQL database password */ define( 'DB_PASSWORD', 'password_here' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' );
You must enter the database name, username, and password that you created previously.
The wp-config.php file should then be saved and uploaded to your WordPress hosting server.
When you go to your website now, it should be operational.
Go to Settings » General after logging into your WordPress admin panel. Then, scroll to the bottom without making any changes and click the ‘Save Changes’ button.
This will ensure that your site’s URL is corrected everywhere it needs to be.
After that, check that all post links are operational by going to Settings » Permalinks, scrolling down, and clicking Save Changes.
Step 7: Update Paths to Fix Images and Broken Links
When transferring a WordPress website from one domain to another or from a localhost (on your PC) to a live site, broken links and missing images are frequent occurrences.
The following SQL query can be used to update the URLs easily.
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.examplesite.com/');
Go to phpMyAdmin, select your database, select ‘SQL’ from the top menu and enter the query above.
Make sure to change the URLs to your own local and live sites before clicking the ‘Go’ button.
WordPress migration from your localhost server (on your PC) to a live site has been completed.
We hope this article helped migrate WordPress from a local server to a live site. You may also be interested in our guide on WordPress For Free – No Domain Or Hosting or our SEO Beginner’s Guide -Best Way To Rank High In Search Engines.