It is always a good idea to develop your website locally as it is fast and easy to fix if you cause an error. The last thing you would want is to have your live site go down. That is why setting up a local install of WordPress is a good idea. This tutorial teaches you how to move WordPress from local server to live site. This includes all of your work that you have done locally and will ensure it looks exactly how it should online.
When you have finished developing your site, you will want to move it to your hosting provider so the world can access your creation. This guide will walk you through how to manually transfer your local WordPress install to your live website. Although there are faster methods by using plugins, we will show you how to transfer WordPress manually.
In this tutorial we will be transferring the site manually from local server to live site to show you how it is done. There are simpler options by using a plugin instead.
The best plugins to transfer your site are WP Migrate DB Pro, Duplicator and BackupBuddy. We personally use WP Migrate DB Pro as it is so much quicker with one-click migration.
What to do before you start?
Before we begin migrating, we will assume you have a local WordPress install setup on your Mac or Windows computer. If you do not then you should stop reading this guide and follow our guide on how to install WordPress on your computer first.
You will also need a domain name and a hosting server setup and ready to use. If you do not have hosting or a domain name then you can read our article on how to choose the right WordPress hosting for your website.
In most cases, if you are just beginning then we recommend Bluehost as they offer affordable website hosting and domain names. If you want hosting with a lot more power then WP Engine is the hosting for you.
Make sure you follow our guide on how to install WordPress on your hosting server if you have just purchased your website hosting and domain name.
Finally, you will need to have an FTP application on your computer. You use the FTP application to connect to your server and transfer the files to it. We use the FTP application called Transmit but all FTP applications will be similar and Filezilla is a free alternative.
Once you have the local install, your hosting server and and FTP application ready then it is time to begin transferring your website to the live server.
Exporting your local install
The first step is to export your local WordPress database. A local database is created on your computer when you use server software such as MAMP, WampServer or XAMPP applications. You may be using other software but the process is very similar. You will need to make sure your local server software is running on your computer to access your database.
-
Go to phpMyAdmin
We are using phpMyAdmin to administer your local database.
In your browser, go to:
[code type=”markup”]http://localhost/phpmyadmin/[/code]
-
Select database
In the left hand menu, select the database of your WordPress install.Tip: If you are unsure of your database name, you can navigate to where your local WordPress install files are located. Find the wp-config.php file in the base folder and open it in your preferred text editor. Near the top of this file should be a line that begins with
define('DB_NAME'
. The value after it in between the apostrophes is your database name. -
Export Tab
Once you have clicked on your database, go to the export tab. If you are installing a fresh version of WordPress then choose the Quick – display only the minimal options.Choose the Custom – display all possible options if you would like more control over the export options. You can set the SQL file to remove any existing data in your databases on your live site for you. You can also choose to remove live sites database entries manually in a later step.
When you are ready, select the Go button to download the SQL file.
[latest_deal length=”full”]
Upload WordPress Files to Live Server
The next part of the process is to upload all of the WordPress files to the live hosting server. To do this, you will need to connect to your hosting server using your File Transfer Protocol (FTP) application.
If you do not have a preferred FTP application, you can download Filezilla. It is a free FTP application that works on all computers.
For this tutorial we will be using Filezilla.
Note: Make sure you follow the install steps closely. One of the install windows will ask to set yahoo as the default search engine and new tab window in your browser. You may not want that. If you don’t, just select “No, thanks”.
-
FTP connect to Live Hosting Server
Install and open Filezilla on your computer.Locate FTP login details
When you first signed up to your website hosting provider, they should have sent an email detailing the FTP logins.The details you need to connect via FTP are:
- FTP server address. (often it will be ftp.yourdomain.com e.g. ftp.web3.com.au or it will be an IP Address e.g. 127.0.0.1)
- FTP Username. (you or your hosting provider will make this username)
- FTP Password. (you or your hosting provider will make this password)
- FTP Port. (For FTP the default port is 21 but could be different depending on your hosting provider. e.g. 22 or 2222)
If they are not available in any emails, you will be able to retrieve these details by logging into your hosting server. Each host provider is different so you may need to contact your hosts support if you need assistance finding this.
In cPanel, you can log in and go to the FTP Accounts section to find available accounts or create a new account. You can also click the Configure FTP Client link to download the logins in a file for Filezilla.Connect to Server
Once you have either got the FTP details or downloaded the FTP configuration file,
Add these details into your FTP application and click connect. -
Copy WordPress to Live Hosting
Once you are connected to your hosting provider via FTP, navigate to the public_html folder in your FTP application. If you connected to the server and can not see any other folders then chances are it is in public_html.On your computer, navigate to where the WordPress files are installed. Copy all of the files in the base folder to the public_html folder in your FTP application. The files you are copying should include all of the wp-example.php files and the wp-content, wp-admin and wp-includes folders among other files. These are the root files of WordPress.
Depending on your internet connection, this will take a while. Just let it work in the background while you continue with the next steps. Make sure you leave your FTP application open as we will need it in a later step.
Setup MySQL Database
The next part requires you to log into your hosting server and create a new database. Once the database is created, you will be importing the SQL file you exported from your local install.
-
Change Site URL
In phpMyAdmin, select your database from the left and then click on the wp_options table.
Tip: If there is no wp_options table then it is likely because your table is using a different prefix. In this case you would click on your *prefix*_options table.Search the list of rows for the two following option_names:
[code type=”markup”]siteurl[/code]
[code type=”markup”]home[/code]Tip: If you can not find the siteurl or home option_names then you may need to go to the next page. If this is the case, scroll to the bottom and click the little > next button.
When you have found the rows, double click on each of their option_values to edit their values. They should be set to the URL of your local WordPress install. You need to update them to the URL of your live site.
Make sure you are using the full address of your site including the http:// or https:// and if you are using it, also the www. So it should look like this for example:
[code type=”markup”]https://web3.com.au[/code]
Click away from the field you are editing to save the updated value. Repeat for both the siteurl and home fields.
Update Live WordPress Configuration
Now that you have updated your site URLs, you will be able to visit your site and see some progress. Though not what you are specifically after. You will see an error message saying that it is unable to connect to your database.
To fix this, you need to update the wp-config.php file on your server to point to your new newly setup database on your live server in the previous step. This section of the tutorial shows you how to update your configuration file so that it can connect to your database.
Before you begin this step, you will need to make sure your files have finished copying to your server in your FTP application. If the files have finished copying to your server then you can proceed.
-
Open wp-config.php
In your FTP application, navigate to the base directory of your WordPress install. This should be the public_html directory and you should be able to see the wp-admin, wp-includes and wp-content folders.Along with these folders you will be able to see a file called wp-config.php. Open this file in your preferred text editor.
You will need to update the following database records with the values you set in the previous steps.
[code type=”php”]/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress’);/** MySQL database username */
define(‘DB_USER’, ‘root’);/** MySQL database password */
define(‘DB_PASSWORD’, ‘root’);[/code]
The DB_NAME field is the name of the database you created and the DB_USER and DB_PASSWORD is the user logins you created in the step after it.Save the file and make sure it is uploaded overwriting the wp-config.php file that was there. You should now be able to view your site live on the internet!
-
Save WordPress Settings
Now that you can access your website, you will need to log in and save your sites settings. This is to ensure that the values that you updated in the database are correctly updated across your site.Log in to your site by going to your live websites admin login page. E.g. https://web3.com.au/login.
Go to Settings > General and scroll down to the bottom of the site and click the Save Changes button for WordPress to do the update.Do the same with the Settings > Permalinks page. Scroll down to the bottom and click the Save changes button to ensure all posts are updated for your live site.
That is all that is required to get your website online though there is one final piece to the puzzle which is fixing links and media still referring to your localhost.
Fixing Broken links and media files not displaying
When you access your site, you will find that your media is not displaying correctly and the URLs that you created for your site still go to your localhost – not your live site. This is because your site is still referencing your localhost URL for media and links in the database.
To fix this, you can either add a plugin to search and replace every record in your database or you can do it manually by running a SQL query in phpMyAdmin on your server.
If you choose to use a plugin then we recommend using Better Search and Replace. It creates a Better Search Replace sub-menu in the Tools sidebar that allows you to search for your localhost URL and then replace it with your live websites URL.
If you would like to do this manually then you can follow the below steps.
-
Go to phpMyAdmin
Navigate back to phpMyAdmin on your hosting servers cPanel.
Select your database from the left hand side and click on the SQL Tab. -
Execute SQL query
The below code replaces your localhost URL with your live sites URL. Note: Make sure you update the below script to reflect your own localhost and live sites URLs.
[code type=”markup”]UPDATE wp_posts SET post_content = REPLACE(post_content, ‘https://web3.com.au’, ‘https://web3.com.au’);[/code]
Copy and paste all of the code (remember to update it with your own URLS) into the SQL field and click the Go button.
That is all that is required. Note that the above code will only search your posts table so if you have other tables made by custom plugins then it is easier to use a search and replace plugin to cover these tables for you.
Congratulations on transferring your local WordPress site on your computer to your live site online! Hopefully all of the steps made sense and you were successfully able to transfer your site without any issues.
If you find yourself doing this on a regular basis then it would be a smart idea to use a plugin like BackupBuddy or WP Migrate DB Pro to do all of the heavy lifting for you. They will save you a lot of time as you will be able to do the above steps in less than half the time.
Did you find this guide on how to move WordPress from your localhost to live site helpful? Let us know if you need a hand with any parts in the comments below.
Also make sure you join us on our YouTube channel for video WordPress tutorials. You can also keep up to date with our latest tutorials on our Facebook page.