The Best Free WordPress Tutorials to Master WordPress

How to Install Localhost WordPress with XAMPP? (3 Steps)

0 853

A localhost hosting environment is essential for any WordPress development project. Doing so will allow you to safely and privately test your site’s features and functionality.

In this guide, we will show you how to install WordPress on localhost with XAMPP to develop and test your WordPress site. We will do this in three stages:

  1. Install XAMPP.
  2. Run XAMPP and configure your environment.
  3. Download and install WordPress.

We will also talk about best practices for you to try WordPress testing and coding using XAMPP. Finally, we will show you how to use XAMPP with WordPress multisite installation. Let’s get to work!

Why You Might Need a Local WordPress Site

A locally hosted WordPress site can only be accessed by people in your network (non-live elements). This type of website can also be used as a safe environment where new features can be tested and debugging methods can be tested.

Local websites are great for the following types of tasks:

  • Creating new themes and plugins: When  using a local site, you don’t have to worry about any of the problems you might have while developing a live WordPress site.
  • Website trial:  You can create a copy of a live website and use this copy for testing purposes.
  • Site debugging and repair:  Trying to fix bugs or other issues on your live site can lead to bigger problems (and ultimately costly downtime). You can try different kinds of solutions by creating a local WordPress site and easily restore previous versions of your site if you do anything.

For these reasons, setting up a locally hosted WordPress site is highly recommended for any development project. But first, you’ll need a tool that will make setting up a locally hosted site quick and easy.

Introduction to XAMPP – What is XAMPP?

If you want to install WordPress on localhost, there are a few important components you will need. These components are a web server software ( such as Apache ), programming languages ​​such as Perl and PHP , and finally a database management system such as MySQL . Installing each of these individually is difficult and takes a lot of time.

XAMPP (short for cross-platform (X), Apache, MySQL, PHP and Perl) allows you to install all these components quickly and easily. Then you can use XAMPP to install localhost WordPress. You can also test plugins, experiment with themes and code, and do other development activities securely on your local WordPress site.

Backed by a large support community , XAMPP is free and open source software. It is extremely lightweight and all the elements needed to set up a local web server are available in an extractable file. Moreover, learning to use XAMPP is quite easy, as we will talk about later.

How to Install Localhost WordPress with XAMPP (3 Steps)

In the following steps, we will show you how to use XAMPP and how to install localhost WordPress with XAMPP. For this guide, we will show our steps through the Mac version of this software. However, XAMPP can also be similarly installed and run on both Windows and Linux devices.

Step 1: Install XAMPP

First, go to the Apache Friends website and download the one for your operating system from the home page:

After the installation is finished, drag XAMPP to your  Applications  folder:

After the initial installation process is completed, XAMPP will be installed on your system. There is nothing you need to do in this part of the setup.

If you are running XAMPP on Windows and there is another program on your machine that uses either port 80 or 443, you may encounter a port error. For example, the Wide World Network (WWW) Publishing Service generally uses port 80 and may conflict with XAMPP.

To resolve this you will need to stop this service by doing the following:

  1. Go to the Windows  Start  menu and  type services.msc  .
  2. Locate the World Wide Web Publishing Service from the Services  window.
  3. Right click and  press Stop  .
  4. Restart XAMPP. If the World Wide Web Publishing Service was causing the problem, the port error would have been resolved.

If this does not solve your problem, your Windows firewall may be causing this problem. To force open your ports, you will need to create a new firewall rule:

  1. Open Windows Firewall and  go to Advanced Settings .
  2. Go to Inbound > New Rule .
  3. Go to Port > TCP . You will need to type 80, 443 in the field named Specific Ports  and then click Next .
  4. Select Allow Connection and then click Next again  .
  5. Make sure all listed options are checked and proceed to the next page.
  6. In the Name  field, enter a name you can remember ( such as host1 ) and  click Finish .
  7. Now you will have to repeat all the steps from 1 to 6 and clean the port again by changing the name (eg  host2 ).
  8. Restart your computer. Ports 80 and 443 will be open locally.

Once XAMPP is installed you will be ready to run.

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 window that appears in front of you:

Now  go to Services . Make sure both Apache and MySQL stack services are running (as they have the green light). This will ensure that your database management and server software elements are ready for your local environment. You can ignore ProFTPD (a configurable file for the File Transfer Protocol server) for now.

If MySQL or Apache are not running (if there is a red light) select them and  press Start  :

Then switch to the Network tab. Here you can set port forwarding rules between your machine and your stack. Select the localhost option you want to work on and press the Enable  button. In this example we will use localhost:8080 :

You will now be able to access your localhost and start using XAMPP as a server environment. To do this, open your browser of choice and enter your localhost name (in our example this would be localhost:8080  ). This will open the XAMPP control panel. Once in the control panel, select the phpMyAdmin  button in the upper right corner of the page :

Next, you will need to create a database for the localhost WordPress installation. To do this, select the  Database  tab, enter a name for your database ( WordPress in  our example  ) and make sure the adjacent dropdown  is set to  Collation  and press Create  :

Now you are ready to learn how to install localhost WordPress with XAMPP.

Step 3: Download and Run WordPress

In this step 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-config-sample.php  file:

Open this file in your preferred text editor (like TextEdit). You will need to find this line of text:

define ( 'DB_NAME' , 'enter_database_name here' ) ;

Enter_database_name_here  and enter the name of the database you created in the previous step. Then find these two lines:

define ( 'DB_USER' , 'enter_user_name here' ) ;
define ( 'DB_PASSWORD' , 'enter_password_here' ) ;

Here, replace the part  named_user_name here_with  root  and delete the part named_enter_password here completely. The result should look something like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define ( 'DB_Name' , 'wordpress' ) ;


/** MySQL database username */
define ( 'DB_USER' , 'root' ) ;


/** MySQL database password */
define ( 'DB_PASSWORD' , '' ) ;

After you’re done, save the file as  wp-config.php  . You will need to make sure this file is located in the htdocs  subfolder in the XAMPP folder  . You will also need to put the WordPress installation folder in the  htdocs folder.

Finally, go to http://localhost/wp/ in your browser  . Then do the standard WordPress installation. After everything is finished, you will have successfully completed the localhost WordPress installation!

How to Install WordPress Multisite on XAMPP

Now that you know how to use XAMPP to set up a single WordPress site, you might want to use the same process to create a multisite network. This allows you to create a network of multiple websites that you can manage from a single WordPress site. There are many applications available for multi-site setup. For example, it allows you to test your newly developed themes or plugins to see how they will work on different sites.

To get started you will need to open your wp-config.php  file in a text editor  . Then add the following lines of code at the bottom of the file * That’s all, stop editing! Happy blogging. You need to add just above the  line:

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

After making sure that Apache and MySQL are still running in XAMPP, login to your localhost site. Then go to  Tools > Network Setup :

Select Install after entering a network header  . You will be prompted to edit the wp-config.php  and  .htaccess  files.

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

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 ) ;

You will then  need to open (or create) the .htaccess  file in the same directory as your wp-config.php  file  . Then replace all the lines with the following:

 

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [ L ]


# add a trailing slash to /wp-admin
RewriteRule ^ ([ _0-9a-zA-Z- ] +/ ) ?wp-admin$ $1wp-admin/ [ R= 301 ,L ]


RewriteCond % { REQUEST_FILENAME } -f [ OR ]
RewriteCond % { REQUEST_FILENAME } -d
RewriteRule ^ - [ L ]
RewriteRule ^ ([ _0-9a-zA-Z- ] +/ ) ? ( wp- ( content|admin|includes ) .* ) $ 2 [ L ]
RewriteRule ^ ([ _0-9a-zA-Z- ] +/ ) ? ( .*\.php ) $ $ 2 [ L ]
RewriteRule . index. php [ L ]


# END WordPress

 

Save and close the file. You should now be able to access all sites after entering your localhost WordPress installation.

What You Can Do With Your Localhost WordPress Installation

After learning to use XAMPP and installing localhost WordPress and getting a local WordPress site, what you can do will depend entirely on the development project you start with. To get started, WordPress.org offers a great beginner’s guide to test-drive WordPress .

If you are interested in developing themes, you  can look at sites like Theme Shaper . You can safely edit your files to test new themes and their functionality using your local environment.

If you want to learn how to use XAMPP and WordPress together to test your coding knowledge and gain more PHP experience, there are many useful guides for that too. Both BitDegree and Code Academy offer a variety of guides covering PHP and HTML basics, and more.

You may want to have resources on hand for troubleshooting and improving your skills while using your local WordPress site to develop. Stack Exchange is a growing online forum where you can ask questions and gain invaluable insights from the WordPress development community. Finally, you should also frequent the WordPress.org support forum .

Conclusion

As you can see, XAMPP is a powerful and versatile solution for setting up a local web server. It’s great for setting up an environment for basic WordPress coding, experimenting with multiple site settings, playing around with themes, and more. However, this is not the only tool you can use to install localhost WordPress. Another great alternative is to install WordPress on localhost using Docker.

Have questions about how to use XAMPP or your new local WordPress site? Share it with us in the comments section below!

You might also like
Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More