Install WordPress Locally using Xampp the Right Way(From Scratch)

A friend of mine ask me, “Can I install WordPress locally on my computer?”

I said, “Of course, just search it on google”

Then after a day, he said he follow all the guides that he search on the internet but it’s not working. He said, some of the links and images are not working properly.

He wanted to “clone” completely his live wordpress website to his computer locally using xampp. So today, I’m gonna teach you on how to install wordpress locally using xampp the right way from scratch.

Install WordPress Locally using Xampp the Right Way 2017

Before we dive into our in-depth step by step guide on how to install wordpress locally, let me first tell you what is the use of running it on your computer.

  • Test your site for some customization if it’s running smoothly.(You don’t want to customize your site alive)
  • Test new WordPress themes and Plugins before uploading it to your live site.
  • More secure and provide ideal testing environment on your PC, thus avoiding hackers
  • If you’re a web developer, xampp is a must tool for you.

If ever, I have forgot something in the list, let me know in the comment section below or contact me and email me.

I provide you the requirements and divide it into 3 sections:

  1. Getting Xampp
  2. Getting your site locally
  3. Troubleshooting

Alright, let’s start.

Install WordPress Locally using Xampp the Right Way

Xampp - Apache Friends

1. Getting Xampp

There are lots of other programs to choose from in which you can install WordPress locally on your computer but Xampp is my best buddy when it comes to creating local server.

What is Xampp?

XAMPP is literally an acronym and it stands for cross-platform(X), Apache, MySQL, PHP and Perl. It’s a simple solution which allows you to create a server locally on your computer.

Because you can create server, you can also create your website or install CMS such as WordPress to create or develop a WordPress site.

Since it’s a cross-platform, it also works on MAC and Linux. But today we’re going to focus only on Windows 10.(That’s my Windows version)

How to install Xampp on Windows

  1. Head over to Apache Friends website and download Xampp.
  2. Xampp is about 109.50 MB and in version 5.6.30 as of this writing.
  3. Once downloaded, launch the installer to start the process.
  4. During the installation process, depending on your settings, you may receive this warning. I usually install Xampp on C:\ so be sure to install it also on C:\Ignore this if you haven’t receive this warning.Xampp Warning
  5. Xampp will guide you through the necessary steps. Just click Next.Xampp Installtion Process
  6. Next is you choose which program components you want to install with Xampp. Apache and PHP are grayed out because it is required to use in a local server. Other are optional but since we need to install WordPress locally, check only MySQL and phpMyAdmin and leave others uncheck.Xampp Installtion Process - Choosing Components
  7. Next is you choose to select the folder where you need to install Xampp. Leave it as C:\xamppXampp Installtion Process - Selecting installation folder
  8. Since we’re installing this manually, uncheck “Learn more about Bitnami for XAMPP” and click Next to start the installing process.Xampp Installtion Process - uncheck
  9. After the installation is complete, depending on your computer security settings, you may receive this alert. Don’t worry, it’s safe so just click “Allow access”Xampp Installtion Process - Firewall Security Alert
  10. Now start Xampp by clicking “Finish”.

Xampp Installtion Process - Finish Installation If you want to start it manually, you need to uncheck “Do you want to start the Control Panel now?”. 

Then you need to your Xampp installation folder(In my case it’s C:\xampp) and start it by double clicking xampp-control.exe

For easy access, you may want to create a desktop shortcut of it. Right click xampp-control.exe then select “Send to” and choose “Desktop(create shortcut)”Create Desktop ShortcutNow you can easily start Xampp manually. Head over to your Desktop and look for Xampp shortcut.

Starting Xampp

As you can see in our previous guide that you have 2 options in starting xampp. One is to start it automatically after the installation and the other is to manually start it.

Either you start it automatically or manually, your Xampp control panel should look like the image below after starting Apache and MySQL

Starting Xampp

Now, we have successfully started Xampp and the local server is running. To check, open your favorite browser and type localhost on the URL then press enter.

Checking Xampp in browser

If you see Xamp’s welcome page, then you’re already set.

2. Getting your site locally

When you want to install wordpress locally and completely clone your site from live to local, you have 2 options. First is to manually install wordpress cms by downloading it from wordpress.org. Second is to backup your live site and copy it on Xampp.

The first option is a bit a lot of work while the second is a bit more easy. Since we are getting our site locally, we just need to create a backup of our live site.

Create a backup of your live site

There are many tools in creating a backup of your site. However, there are only 3 important files you need to make a copy of your live site:

  1. The contents of public_html folder
  2. The MySQL database
  3. Email Accounts(optional)
Download public_html folder

You need to download this individually or download this in one zip file by creating a full backup of your site. However, I prefer to download this individually.

How do you backup your site?

Just go to your cpanel provided by your hosting like namecheap or bluehost then look for backup or backup wizard to start the process.

Another option is to use a ftp manager such as FileZilla. Open FileZilla and enter your host server, username, password and port(default port for ftp is 21) provided by your hosting when you signup to them.

Go to C:\xampp\htdocs\ and make a folder. I usually name the folder after my site. For example, blogtrainee folder.

After that, just transfer the contents of public_html folder to blogtrainee folder.

Now open your browser and type localhost/blogtrainee. (blogtrainee is the folder which you previously created.)

If you have a database connection error, then your good to go.

Database error

Get MySQL database from live site
  1. Go to your cPanel then choose phpMyAdmin then export your database. Another option is to go to cPanel, look for backup then select Download MySQL Database. After you download it, you need to import it to your local server.
  2. Open Xampp control panel then click Admin on MySQL. Or you can directly go to your browser and type localhost/phpmyadmin/Xampp phpMyAdmin
  3. From your left side, click “New” to create new database.
  4. Enter database name that’s the same as your live site then click Create.Create Database on phpMyAdmin
  5. Select the database on the left side(the database that you have created on step 4) that you should be working with to import the live site’s database. Then click Import tab. Then choose your database that you have downloaded from your live site.
  6. Leave the other settings as is and click “Go” below.
  7. After importing, click again your database on the left then this time, click SQL tab. Now copy and paste the code below:

    UPDATE wp_options SET option_value = replace(option_value, 'http://www.yourlivesite.com', 'http://localhost/yourlocalsite') WHERE option_name = 'home' OR option_name = 'siteurl';

    UPDATE wp_posts SET post_content = replace(post_content, 'http://www.yourlivesite.com', 'http://localhost/yourlocalsite');

    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.yourlivesite.com','http://localhost/yourlocalsite');

  8. Replace the prefix “wp” base on your table prefix. Replaced yourlivesite.com with your site and replace yourlocalsite with your local site folder.
  9. NOTE: the folder is the folder that we have created earlier. In my case it’s blogtrainee folder. So I put localhost/blogtrainee. Don’t forget to click “Go”.SQL Xampp

 

Edit wp-config,php

Go to C:\xampp\htdocs\blogtrainee and edit wp-config,php with notepad or any text editor.

Edit this:

DB Name = Enter your database name that you have created on step 4 above.

DB User = we can make custom user but for this, just put root

DB Password = Leave it blank or remove if you have password

DB Host = localhost

Then leave other settings as is then Save it. The final look will be something like this:

Edit wp-config database settings

 

Lastly, go to your browser and type localhost/yourlocalsite and it will load the local copy of your site just like mine.

Final Output

 

3. Troubleshooting

Even if you followed my step by step guide above on how to install wordpress locally using Xampp, you will encounter errors if you have any.

Lucky for those who did not receive any errors.

I have listed the problems that I have encounter and so far, this is all tried and tested. I always tried it myself if it’s working or not.

So if you have problems other than I listed here, just leave a comment below.

Xamp Port Problems

When you encounter port conflict problems or something like that, you need to change the ports of Apache. By default, Apache uses port 80 and 443 for browsing but you can change that since this is only a local server.

Click Config on Xampp Control Panel

Xampp Apache Port Configuration

Then click Service and Port Settings

Server and Port Settings

Now change the port something like 54321 and 54322 then click Save. Then restart Xampp.

Rename Cache Plugin Folder

404 Page

When you’ve done all of my steps above and your local site does not load properly, then you need to removed or rename your cache plugin.

Go to C:\xampp\htdocs\blogtrainee\wp-content\plugins then rename the cache plugin folder. In my case I use W3 total Cache, so I rename it like this:

Renamed Cache Plugin

Now clear your browser cache then try open your local site.

Rename Google reCaptcha plugin folder

When you have google recaptcha plugin installed, then you cannot login on your local site unless you removed it.

However, we will not remove it. We will just rename the plugin folder just like we did in cache plugin.

Renamed Google reCaptcha

Then after renaming, viola, you can now login without reCaptcha.

Login without Google reCaptcha

Cannot view your posts/articles

When you cannot view your post or it return a 404 error or you are directed to Xampp welcome page, then you have problems with permalinks.

You just need to update the permalinks settings in your WP dashboard. Go to Settings then click Permalinks.

Now don’t change anything, just click Save Changes.

Go to your local site and browse your articles with no errors whatsoever.

 

Into You!

So to install wordpress locally using Xampp, we do these steps:

  1. Install Xampp
  2. Copy the contents of public_html folder from your live site.
  3. Export your live sites database
  4. Create your local database in phpMyAdmin and import the database on step 3
  5. Change wp-config,php database settings
  6. Then troubleshoot if somethings went wrong.

Hows the process goes to you? If you have problems don’t forget to comment below.

About the author

Ronald

Ronald is the man behind blogtrainee.com. He loves to write tutorials on how to start a blog from scratch and to rank them and make money.

Leave a Comment