Having a local hosting for your WordPress website is an important & common thing among site owners and developers. It enables the site owners to test new themes/plugins or a script locally that you were not aware of in past in their computer before using them on a live website, without worrying about breaking the live WordPress site.
Some other benifits of having localhost are:
- The site in your localhost runs much faster than the online site.
- More secure as no one wants to hack the localhost.
- It’s private. Only you will be able to see the localhost website site. So, you don’t need to worry even if you break any code or the entire website.
- It’s free.
- There would be no downtime i.e., your website on localhost is always online.
- It works even without Internet connection.
As WordPress needs a server to run, we need to make an arrangement that provides the ‘server environment’ for WordPress in our PC. In this tutorial, I’ll explain how to run a WordPress site locally using XAMPP (X-Platform, Apache, MySQL, PHP & Perl) that provides the server environment for WordPress.
If you want to move your existing WordPress website to the localhost, you can read this article.
By the end of this tutorial, you’ll be able to install a WordPress testing site locally on Windows using XAMPP.
(I’ve used a Windows 10 machine in this tutorial. However, the installation process is almost similar on other platforms).
Once downloaded open the software by double-clicking on the setup file. When installing XAMPP, you may receive a warning from your Anti-Virus software and UAC (User Account Control) as well. But there is nothing to worry about. XAMPP is completely safe to use. You can just click yes to continue.
When you’re in the ‘Select Components’ section, you may observe that ‘Apache’ and ‘PHP’ options are already selected and you can’t unselect it. To run WordPress we need to select
as shown below. Remaining are not necessary but you can select them as per your requirements.
After that, you will have to choose where to install the XAMPP and you can leave this default. But remember one thing if you want to change the installation folder. As this is the root directory for your website you may want to visit this folder again and again in Explorer. So, you might want to choose a directory that has easy navigation.
You can also choose if you want to install Bitnami, a free tool that will help you install WordPress from the XAMPP. But to have more control over the installation, we’ll uncheck this.
And then there would be the final button to complete the installation of XAMPP. Just click it and wait for a few minutes for the installation to get completed.
After the installation gets completed, please leave the checkbox active and click on Complete. Your firewall might welcome you with a warning message and you need to select ‘Allow Access’ otherwise XAMPP will not work as intended. After this, you might see something like
You can observe that we are only able to select Apache and MySQL from the image above. This is because we have installed only those. Now click on both start buttons and now you’re good to go with WordPress installation.
You have now completed the first step.
Creating a server environment for WordPress
As mentioned before, WordPress needs a server environment to run. So, we need to create a database for your WordPress website with XAMPP using phpMyAdmin.
1) Access the phpMyAdmin page by typing “localhost/phpMyAdmin” in your web browser’s address bar.
2) Once you’re in the phpMyAdmin page, click on the “databases” menu on the top menu-bar to create a new database for your website. You can use any name and we’re going with ‘test’ this time. Remember this name as you need it later when installing the WordPress on your machine. After that, press on the ‘create’ button.
When the new database is created, you can see that on the left sidebar of the phpMyAdmin page. By default, it is empty if you select the database on the left sidebar but will get populated after installing WordPress.
Now, we can proceed with the installation of WordPress on your machine.
If you have already installed WordPress manually ever before, this step is almost as same as that. Download the zip file of WordPress by going wordpress.org and save it somewhere on your machine.
Now, please navigate into the folder where you have installed XAMPP and open it. You will see a folder called ‘htdocs’ and this is the folder where you need to extract your website files.
Extract the WordPress zip into this folder and rename it to something you could remember, (testsite in this tutorial) so that you can identify it easier and also, this name will be your localhost’s website URL (localhost/testsite in this tutorial).
The extraction will take some time even though the zip file is under 15MB 😉
After completing the above step, you need to open a web browser and enter the following address in address bar.
Which is “localhost/testsite” in this case.
It will open a starting page like the following.
Select your desired language and click on continue.
You will encounter another page like this.
Click on Let’s Go
On the next step, please enter the following database information
Database Name: test (Your database name that you have created earlier)
Password: (Leave blank)
Database Host: localhost
Table Prefix: (Leave it as it is)
And click on Submit
Aaaaalll right sparky….. Just click on ‘Run the installation’
Enter the details of your choice.
Site Title – Website’s Title
Username – You need this to log in later
Password – You need this to log in later
Your Email – You don’t need to provide a valid email
Search Engine Visibility – (leave it unchecked)
After filling the details click on ‘Install WordPress’.
Then You will be provided a login page and just log in with the credentials given by you before.
From now on, you can log in to your website by going to /localhost/testsite/wp-admin page and use the username amd the password that you have entered during the installation to login.
And, please note that you need to start the Apache & MySQL services from XAMPP whenever you want to login to your localhost website.