How To Move WordPress From Localhost To Live ServerPosted by TotalDC
So you made WordPress website on localhost and now want to make it live for everyone to see it? In this article we will be looking at how to move WordPress from localhost to live server. Let’s start!
How to move WordPress from localhost to live server?
It’s really good to build a website locally for the speedy development. Even, it saves you from unnecessary headaches of breaking your site while troubleshooting. You can safely test your site for changes and make your workflow more efficient. Once you are satisfied with the design of the website, you can transfer it to the live server. Actually it’s easier than it sounds.
First you need a hosting plan to upload your WordPress website. I would highly recommend Hostinger. Because it has one of the best prices and their customer support is superb.
Methods to Move WordPress from Localhost to live Server and Publish Website
First of all, you will design and test your WordPress website on localhost. For that, you need to install WordPress and WAMP (or MAMP or XAMP, depends on your OS) . For details about setting up a local environment, you can refer to my article on how to install WordPress and WAMP locally. Once you are sure about the performance of your website, you can move it to the server.
Now if you already have your domain and hosting, let’s see how to make your website live step by step.
How to move WordPress From Localhost To Live Server
To move your WordPress site manually, you will first export it via phpMyAdmin.
Step 1: Export Local WordPress Database
For exporting your database, simply navigate to http://localhost/phpmyadmin/ and select your WordPress database. Next, click Export button from the top menu bar.
You will find two options here – Quick and Custom. Custom will give you more options to export your database.
If you are choosing Custom, make sure that all the tables get selected. Choose the gzipped form of compression for the output file. The gzipped compression is mainly used for large database files.
Under Format-specific options, select structure, and data. Also, check the following boxes:
- Add DROP TABLE / VIEW / PROCEDURE / FUNCTION statement
- IF NOT EXISTS
- Enclose table and column names with backquotes
Once done, click Go button to download the database file.
Step 2: Upload WordPress Files to Live Site
To move your WordPress files, open your FTP client. For demonstration purpose, we are using FileZilla FTP client here. First, connect to your web hosting account and browse the root directory of your live server. Then, Upload all the files in the right destination directory. For example, if you want to host the site on mysite.com, then upload all files in public_html directory. You will get an inbuilt File Transfer feature on your CPanel if you are using a good Web Hosting like Hostinger.
Step 3: Create New Database on Live Site
Your WordPress files will take a while to upload, meanwhile import the database saved to your hard drive in the first step. Hosting providers offer different ways to do so. Some do it through phpMyAdmin & some via cPanel. The cPanel is more popular so we are creating a database via cPanel here.
First of all, log in to your cPanel dashboard. Click the MySQL Databases icon in the databases section. Top Hosting providers i.e Hostinger. generally provide a direct link to the CPanel login in the first signup email, otherwise you can also find it from your hosting admin.
There you have to create a database by specifying its name. After creating a database, navigate to the MySQL Users section. Here, create or add an existing user to the database. cPanel will take you to set MySQL privileges for that user. Now, grant all privileges to the user by checking every box. Then, click Make Changes button.
Step 4: Import Local Database on Live Site
Go to your cPanel dashboard to import your WordPress database. Navigate to database section and select phpMyAdmin. Now, you can see your newly created database in phpMyAdmin. Go to Import page by clicking the Import Tab on the top bar menu. Next, click on Browse button to choose the database file created in step 1.
Then, press Go to import your WordPress database.
Step 5: Redirect the Site URLs
Now you have to replace all the links in the database contained inside are still pointing to the old site location. In phpMyAdmin, look for the wp_options table in your database. Click Browse button or the link in the sidebar to open the page with a list of fields within the wp_options table. Under the options_name file, you need to look for siteURL. Click Edit option that will open an edit field window.
In the input box for option_value, you can see the URL of your local install like http://localhost/test. Replace it with your new site URL in this field, for example, http://www.yoursitename.com. And save the changes by clicking the Go button.
Next, you will repeat the same steps for the option name: home. So, simply find the home tab in the wp_options page. Update the home URL to be your site URL.
Step 6: Set Up Your Live Site
Once you import the database, it’s time to configure wp-config.php. Connect to your website using an FTP client, find wp-config.php file and right click to View/Edit. Look for the information:
Enter the database name, user, and password you created in the earlier step. After that, save the wp-config.php file and upload it back to your server. Your website should be live now so you can log in. Move to Settings » General and without changing anything, Click Save Changes button. It will ensure that the site URL is corrected wherever needed.
Go to Settings → Permalinks, choose your preferred URL structure and save it to ensure all post links are working well.
Step 7: Fix Images and Broken Links
Whenever you move from local server to a live site, it is obvious to get some broken links and missing images. If you choose SQL, go to phpMyAdmin. Click on your database and press SQL from the top menu. Write this query:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yoursitename.com/');
Replace the local site and live site URLs with your own.
And that is it ! You have successfully migrated your site to the live server manually.
Leave a Reply