Guide to installing WordPress on localhost using XAMPP

Hướng dẫn cài WordPress trên localhost bằng XAMPP

Setting up a WordPress website on localhost using XAMPP is crucial for testing features and functionality in a safe, private environment. This process involves installing XAMPP, configuring the environment, and downloading and running WordPress. XAMPP, a free and open-source software, simplifies installing Apache, MySQL, PHP, and Perl components needed for localhost. Running WordPress on localhost allows for theme and plugin creation, website staging, and easy debugging. Additionally, the guide covers setting up WordPress multisite on XAMPP. Leveraging XAMPP for local WordPress development can enhance theme development, provide PHP practice, and access valuable online resources for support and learning.

Setting up an internal hosting environment is an important step in any WordPress website development project. It allows you to test your website’s features and functionality safely, in a completely private environment. This article will guide you on how to install WordPress on localhost XAMPP. You will successfully install your WordPress website in just 3 steps:

  1. Install XAMPP.
  2. Run XAMPP and configure the working environment.
  3. Download and run WordPress.

We will also discuss some of the best ways to test code and test WordPress sites using XAMPP. Finally, we also show you how to use XAMPP for collaboration Install WordPress multisite. Let’s keep learning!

Why do you need a WordPress website on localhost?

A WordPress site on localhost is a site that can only be accessed within the local network (not the internet). As such, this type of website can be considered a safe environment in which you test new features and come up with solutions to fix problems.

Internal websites are good at performing the following types of tasks:

  • Create new themes and plugins: When using an internal website, you do not have constant worries like on an online website.
  • Website Staging: Staging website is a copy of the main website, used for testing.
  • Debug and troubleshoot websites: Fixing errors directly on a running site can lead to bigger problems (and, potentially, downtime). By using a localhost WordPress website, you can try different ways to fix errors and easily restore the original version if the fix fails.

For these reasons, creating a WordPress website on localhost is highly recommended when developing a project. However, first, you need to know how to install WordPress on localhost. The most common method is to use XAMPP as the localhost environment to install WordPress.

See also  Guide to Speeding up WordPress with WP Rocket

What is XAMPP?

To install WordPress on localhost, you need a core software suite. These include web server applications such as Apache, programming languages like Perl and PHP, and database management software – MySQL. However, installing each component separately is quite time-consuming and troublesome.

XAMPP is the abbreviation for cross-platform, Apache, MySQL, PHP, and Perl. It allows you to install all elements quickly and easily. You can then use XAMPP to set up the necessary environment to run WordPress on localhost. There, you can test plugins, test themes and programming, and develop your website safely. XAMPP is free and open-source software, supported by a big community. The software is also very lightweight, and all the elements needed to set up a local web server are contained in a single, decompressible file. Furthermore, using XAMPP is relatively simple. Therefore, we will quickly guide you to install WordPress on localhost via XAMPP right here.

Instructions for installing WordPress on localhost in 3 steps

In the following steps, we will show you how to use XAMPP and install WordPress on it. For this guide, we will cover the steps for the Mac version of the software. However, you can also get XAMPP up and running relatively easily on both devices Windows and Linux with the same procedure.

Step 1: Install XAMPP
First of all, you need access Apache Friends website and select the appropriate download link on the home page. Next, drag XAMPP into the folder Applications. Once the download sequence is complete, XAMPP will be installed on your system. This part doesn’t require you to do much.

If you are running XAMPP on Windows and have another program on your computer that is using port 80 or 443, you may encounter port errors. To resolve this issue, you need to stop that service from running. If this doesn’t solve the problem, it may be caused by the firewall on your Windows machine. To force unlocking your ports, you need to set up a new firewall rule.

Once XAMPP is installed, you can now use XAMPP.

Step 2: Run XAMPP and configure the environment to install WordPress
Now, open the XAMPP application and press the button Start. You will see a green light in the upper right corner of the screen. Next, navigate to the tab Services. You will need to ensure that the status of both the Apache and MySQL services are running (i.e. both have a green light). This is to ensure that the database management system and software elements are ready for the localhost environment. For now, you can ignore ProFTPD.

See also  Top 3 Business Ideas on WordPress Platform for Developers

If MySQL or Apache are not running, simply select them and press Start. Then switch to the Network tab. Here, you can define port forwarding rules between the server and the XAMPP software suite. You will now be able to access localhost and start using XAMPP as your server environment. To do this, open your favorite web browser and enter your localhost name (currently localhost:8080). This will bring up the XAMPP dashboard. Once there, select the button phpMyAdmin in the top right corner of the page. After that, you need to create a database to install WordPress on localhost.

Step 3: Download and run WordPress
At this point, you need to go to WordPress.org and download the latest version of WordPress. Open the WordPress folder on your computer, unzip and find the file wp-sample-config.php. Open this file in your preferred text editor. Save the file as wp-config.php. Before installing WordPress on localhost, you need to copy and put the entire file content in the WordPress installation folder into a subfolder of htdocs in the XAMPP folder. You can name this subfolder arbitrarily, we named it WP. Next, you just need to move in http://localhost/wp/ in the browser. Once there, follow the standard WordPress installation process. When finished, you will have a WordPress website on your localhost machine!

How to set up WordPress Multisite on XAMPP

Now that you know how to install WordPress on localhost using XAMPP, you might want to use it to create a WP multisite network. This allows you to create and manage multiple websites from a single interface. There are many applications when using multisite. For example, you can use it to test how a new theme and/or plugin performs on various websites.

To get started, you need to reopen the file wp-config.php in the text editor. Then you add the following code at the bottom, just above the line That’s all, stop editing! Happy blogging.

define('WP_DEBUG', false);
define('WP_ALLOW_MULTISITE', true);

Once you’re sure Apache and MySQL are still running on XAMPP, log in to the localhost website. Then navigate to Tools > Network Setup. Once you’ve entered the network title, select it Install. You will be prompted to edit the file wp-config.php and .htaccess.

See also  Handling Incorrect format parameter error when entering data

Open the file wp-config.php once again. You need to add the following code below the lines you added before:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Next, you must Open (or create) .htaccess file in the same directory as the file wp-config.php. Then, replace all existing lines in that file with the given code. Save the file and close. Now, you will be able to access your individual sites in the same dashboard when logged into localhost WordPress.

What is the benefit of installing WordPress on localhost? What can I do?

Once you know how to leverage XAMPP to install WordPress locally, what you do next will largely depend on the type of development project you’re working on. To help you get started, WordPress.org has created a great beginner’s guide Test drive WordPress.

If you are interested in theme development, you can check out our guide on How to develop WordPress themes. Or you can see more websites like Theme Shaper. Thanks to the local environment, you can safely edit files.

If you want to learn how to use XAMPP and WordPress to test your programming knowledge and gain more PHP experience, there are some useful tutorials that can help you. BitDegree and Code Academy both offer many great tutorials that cover PHP and HTML fundamentals, and more.

When using localhost/WordPress, you may need additional resources to develop your personal skills. Stack Exchange is a very active online forum where you can ask questions of the WordPress development community, as well as receive invaluable information. Finally, you will probably need regular activity on WordPress.org support forum.

Conclusion

As you can see, XAMPP is a powerful and flexible solution for setting up a local web server. It creates the most perfect environment for WordPress programming. You can also set up multisite, adjust themes and more. However, this is not the only tool you can use to install WordPress on localhost. Another great alternative is to install WordPress using Docker.

Do you have any questions about installing WordPress on localhost? Or do you want to share your new local WordPress website experience? Let us know in the comments below!


Author:

Hai G. is an expert in managing and operating website services. He has many years of experience in VPS, Hosting, technical SEO, CMS. Especially love WordPress and have been using it for more than 5 years. His hobbies are reading, blogging, traveling and advising young people to start a business.

5/5 - (1 vote)

Related posts