Setting up a locally hosted environment is a crucial step in any web development project, and you can do it with XAMPP on WordPress. Doing this allows you to safely test the features and functionality of your website or blog, on a site that will be completely private.
In this article we will explore how to use XAMPP to set up a local web server so you can develop and test your WordPress site. This involves three steps:
- Install XAMPP.
- Run XAMPP and configure your environment.
- Download and run WordPress.
What could you use a local WordPress site for?
A locally hosted WordPress site is one that can only be accessed by people on your network (that is, there are no active components). As such, this type of site can serve as a safe environment, in which new features and troubleshooting methods can be tested.
Local websites are perfect for the following types of tasks:
- Creating New Themes and Plugins – By using a local site, you don’t need to worry about any of the hassles you might encounter when developing a live WordPress site.
- Website testing: You can create a copy of a live website, which can then be used for testing purposes.
- Site debugging and troubleshooting – Running your live site in the background to resolve bugs or other issues could lead to bigger issues (and potentially costly downtime). By creating a local WordPress site, you can try various solutions and easily restore previous versions of your site in case you make a mistake.
For these reasons, creating a locally hosted WordPress site is highly recommended for almost any development project. But first you’ll need a tool that makes the process of setting up a locally hosted site quick and easy.
An introduction to XAMPP
Some crucial ingredients are needed if you want to install WordPress locally. These consist of web server software (like Apache), programming languages, like Perl and PHP, and database management software (MySQL). However, installing each of these items separately is time consuming and difficult.
XAMPP (an acronym for cross (x) -platform, Apache, MySQL, PHP and Perl) allows you to install all of these elements quickly and easily. You can then use XAMPP to set up the environment required to run WordPress on a local machine. There, you can test plugins, experiment with themes and lines of code, and carry out other development activities safely.
XAMPP is free and open-source software, backed by a sizeable support community. It is also extremely lightweight, and all the elements necessary to configure a local web server are contained in a single removable file. Also, learning to use XAMPP is relatively straightforward, as we will see below.
How to use XAMPP to set up a local WordPress site (in 3 steps)
In the following steps, we will show you how to use XAMPP and install WordPress locally. For this tutorial, we will cover the steps for the Mac version of the software. However, XAMPP can also be configured and run relatively easily on Windows and Linux devices, using a similar process.
Step 1: Install XAMPP
First, you will need to go to the Apache Friends website and select the corresponding download link on the home page:
Then drag XAMPP to your Applications folder:
Once the initial load sequence is complete, XAMPP will install on your system. This part of the setup process doesn’t require much on your part.
We should mention that if you are running XAMPP on Windows, and another program on your machine is using ports 80 or 443, you may run into a port error. For example, the World Wide Web Publishing Service program commonly uses port 80 and may cause a conflict with XAMPP.
To solve this, you will have to stop the execution of that service by doing the following:
- Go to the Windows Start menu and type services. MSc.
- In the Services window, find the World Wide Web Publishing Service.
- Right click on it and select the Stop button.
- Restart XAMPP. The port error will be resolved if it was caused by the World Wide Web publishing service.
If this does not solve the problem, it may be the Windows firewall that is causing it. To force the unblocking of your ports, you will need to configure a new firewall rule:
- Open Windows Firewall and navigate to Advanced Settings.
- Go to Inbound> New rule.
- Go to Port> TCP. You will have to type 80,443 in the field called Specific ports, then click Next.
- Select Allow connection, then click Next
- Make sure all the options listed are checked and continue to the next page.
- In the Name field, enter a name you can remember (such as host1) and select Finish.
- Now you will have to repeat steps 1 to 6, changing the name again (that is, to host2) to delete the port.
- Restart your computer. Ports 80 and 443 should now be unlocked and opened locally.
Once XAMPP is installed, it is ready to start running.
Step 2: Run XAMPP and configure your environment
Now, open the XAMPP application and press the Start button. You should see a green light in the upper right corner of the screen:
Next, navigate to the Services tab. You will need to make sure that the status of the Apache and MySQL stack services are running (that is, they have a green light). This will ensure that your database administration and server software elements are in place for your local environment. For now, you can ignore Profited (which is a configurable File Transfer Protocol server).
If MySQL or Apache are not running (if they show a red light), just select them and press Start:
Then switch to the Network tab. Here, you can define the port forwarding rules between your host machine and your stack. Select the localhost option you want to work on and then hit the Enable button. In this example, we will use localhost: 8080:
Now you can access your local host and start using XAMPP as your server environment. To do this, open your preferred web browser and type your local hostname (which in our case would be localhost: 8080). This will open the XAMPP dashboard. Once there, select the phpMyAdmin button in the upper right corner of the page:
Then you will have to create a database for the WordPress installation. To do this, select the Database tab, type in a name for the database (in our case, we’ll just use WordPress), make sure the next dropdown is set to Collation, and then hit Create:
Step 3: download and run WordPress
At this point, you will need to go to WordPress.org and download the latest version of WordPress.
Open the WordPress folder on your machine and locate the wp-sample-config.php file.
Open this file in your preferred text editor (like TextEdit). You must locate this line of text.
Replace database_name_here with the name you gave your database in the last step.
You will need to replace username here with root and remove password here entirely. The resulting text should look like this: Once you’ve done that, save the file as wp-config.php. You will need to make sure that it is located in the htdocs subfolder within the XAMPP folder. You will also need to paste the WordPress installation folder in htdocs.
Finally, navigate to http: // localhost / wp / in your browser. Once there, follow the standard WordPress installation procedure. When everything is ready, you will have a locally hosted WordPress site ready to go!
How to configure WordPress Multisite in XAMPP
Now that you know how to use XAMPP for a WordPress site installation, you may want to use it to create a multisite network. This allows you to create a network of websites that are managed from a single WordPress installation. There are many applications for a multi-site installation. For example, it presents a useful way to test how your newly developed themes and / or plugins will perform on a variety of sites.
To get started, you’ll need to reopen your wp-config.php file in a text editor. Then, you will need to add the following lines of code at the bottom, just above the line * That’s all, stop editing! Happy blogging.
Once you’ve entered a network title, select Install. You will be prompted to edit your wp-config.php and. htaccess.
Open your wp-config.php file one more time. You will need to add the following code below the lines you added earlier.
Next, you will need to open (or create) your .htaccess file in the same directory as your wp-config.php file. Then replace all existing lines in that file with the following snippet.
Save the file and close it. Now, you should be able to access individual sites on your dashboard when you log into your local WordPress installation.
What you can do with your local WordPress installation
Once you know how to use XAMPP and have a local WordPress site to experiment with, what you do next will largely depend on the type of development project you are embarking on. To get started, WordPress.org offers a great beginner’s guide on how to test WordPress.
If you are interested in developing themes, you can check out our guide on how to develop a WordPress theme or visit sites like Theme Shaper. Using your local environment, you can safely edit your files to experiment with new themes and their associated functionality.
If you want to learn how to use XAMPP and WordPress together to test your programming knowledge and gain more PHP experience, there are a number of helpful guides for that as well. Bit Degree and Code Academy offer an excellent variety of tutorials covering the fundamentals of PHP, HTML, and much more.
While using your local WordPress installation for development, you’ll also want to have resources on hand to troubleshoot and hone your skills. Stack Exchange is a great online forum where you can ask questions of the WordPress development community, as well as get invaluable information. Finally, you probably want to visit the WordPress.org support forum frequently.