input license here

Instructions to install WordPress on localhost using XAMPP






Instructions to install WordPress on localhost using XAMPP


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 securely, in a completely private environment. This article will guide you to install WordPress on localhost using XAMPP. You will successfully install your WordPress site 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 code and test WordPress sites using XAMPP. Finally, we even show you how to use XAMP to combine cài WordPress multisite. Let's keep learning!


Why do you need a WordPress website on localhost?


A WordPress site on localhost is a site that is only accessed within the intranet (not the internet). As such, this type of site can be viewed as a safe environment in which you test new features and work out solutions to problems.


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



  • Create new themes and plugins: When using the internal website, you don't have constant worries like on the online website

  • Website Staging: Staging website is a copy of the main website, used for testing.

  • Debugging and Troubleshooting Websites: Fixing bugs 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 the error and easily restore the original if that doesn't work.


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


What is XAMPP?


To install WordPress on localhost, you need a major 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 (x)-platform, Apache, MySQL, PHP and Perl. It allows you to set all the elements quickly and easily. You can then use XAMPP to set up the environment needed to run WordPress on localhost. There, you can test plugins, test themes and code, and safely develop the web.


XAMPP is free and open source software, supported by community big. The software is also very lightweight, and all the elements needed to set up a local web server are contained in a single, decompressable file. Moreover, using XAMPP is relatively simple. So, we will quickly guide you through installing WordPress on localhost via XAMPP right here.


How to install 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 tutorial, we'll cover the steps for the Mac version of the software. However, you can also get XAMPP up and running with relative ease on both devices Windows and Linux, with the same procedure.


Step 1: Install XAMPP


First of all, you need to access Apache Friends website and select the appropriate download link on the homepage:


What is XAMPP?


Next, drag XAMPP into the folder Applications:


drag XAMPP to Applications folder


Once the download sequence is complete, XAMPP will be installed on your system. This part doesn't ask you to do much


Note that if you are running XAMPP on Windows and have another program on your machine that is using port 80 or 443, you may experience port errors. For example, the World Wide Web Publishing Service program often uses port 80 and can cause conflicts with XAMPP.


To work around this, you need to stop the service from running by doing the following:



  1. Go to Windows menu Start, and type in services.msc.

  2. In the window Services, tìm World Wide Web Publishing Service.

  3. Right click on it and select button Stop.

  4. Restart XAMPP. Port errors should be resolved if World Wide Web Publishing Service is the culprit.


If this doesn't solve the problem it could be caused by the firewall on your Windows machine. To force unlock your port, you need to set up a new firewall rule:



  1. Open Windows Firewall and navigate to Advanced Settings.

  2. Move in Inbound > New Rule.

  3. Move in Port > TCP. You must enter 80,443 in the field labeled Specific Ports, then click Next.

  4. Choose Allow the Connection, then click Next once again.

  5. Make sure all the options listed are checked and then continue to the next page.

  6. In schools Name, enter a memorable name (such as host1) and select Finish.

  7. Now you need to repeat steps 1 to 6, changing the name again (i.e. to host2) to remove the port.

  8. Restart the computer. Ports 80 and 443 are now unblocked and open on the local machine.


Once XAMPP is installed, you can now use XAMPP.


Step 2: Run XAMPP and configure the environment to install WordPress


Now open the XAMPP app and press the . button Start. You will see a green light in the upper right corner of the screen:


start xampp


Next, navigate to the tab Services. You will need to make sure that the status of both the Apache and MySQL services is running (i.e. green lights). This is to ensure that the database management system and software elements are available for the localhost environment. For now, you can skip ProFTPD (which is a configurable File Transfer Protocol server).


If MySQL or Apache are not running (if showing a red light), just select them and press Start:


enable apache mysql


Then switch to tab Network. Here you can define port forwarding rules between the server and the XAMPP suite. Select the localhost you want to work with, then press the . button Enable. In this example we will use localhost:8080:


enable network localhost xampp


You should now be able to access localhost and start using XAMPP as a 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. Then, select the button phpMyAdmin in the top right corner of the page:


phpMyAdmin button on XAMPP Dashboard


Then you need to create a database to install WordPress on localhost. To do this, select the tab Database, enter a name for your database (in our case, simply WordPress), make sure the next dropdown is set to Collation, then press Create:


tao database trong phpMyAdmin Database Tab


Now you can install WordPress on XAMPP.


Step 3: Download and Run WordPress


At this point, you need to go to WordPress.org and Download the latest version of WordPress:


WordPress download page on WordPress.org


Open the WordPress folder on your computer, extract and find the file wp-sample-config.php:


wpconfig sample configuration file


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


define('DB_NAME', 'database_name_here');

To replace database_name_here with the name you gave the database in the last step. Then find these two lines:


define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');

You need a replacement username_here is equal to root and delete it completely password_here. The result will be as follows:


configure wp-sample-config file to install WordPress on localhostPlease save the file under the name wp-config.php. Before installing WordPress on localhost, you need to copy and put all the file contents in the WordPress installation directory into a subdirectory of htdocs in the XAMPP folder. This subdirectory you name arbitrarily, we name it WP.


Next you just need to go to http://localhost/wp/ in the browser. Once there, follow the standard WordPress installation process. When it's done, you'll have your WordPress site 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 works on various websites.


To get started, you need to open the file again wp-config.php in a 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 site. Then navigate to Tools > Network Setup:


Select the WordPress Network Setup item


After you have entered the network title, select Install. You will be prompted to edit the file wp-config.php and .htaccess.


Open file wp-config.php once again. You 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);

Next, you must open (or create) .htaccess file in the same directory as file wp-config.php . Then, replace all existing lines in that file with the following code:


# 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 the file and close it. You will now be able to access your own websites in the same dashboard when logged into localhost WordPress.


What is the use of installing WordPress on localhost, what can be done?


Once you know how to leverage XAMPP to install WordPress on your local machine, 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 to Test drive WordPress.


If you are interested in theme development, you can check out our guide on How to develop a WordPress theme. Or you can see more websites like Theme Shaper. Thanks to the internal 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 experience with PHP, there are some helpful tutorials that can help you. BitDegree and Code Academy both provide great tutorials covering the fundamentals of PHP and HTML, and much 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 to the WordPress development community, as well as get invaluable information. In the end, you'll probably need to be active on the WordPress.org support forum.


Conclude


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 multisites, customize themes and much more. However, this is not the only tool that you can use to install WordPress on localhost. Another great alternative is to install WordPress using Docker.


Do you have any questions about the process of installing WordPress on localhost? Or do you want to share your new local WordPress site experience? Let us know in the comments section 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 over 5 years now. His hobbies are reading, blogging, traveling and mentoring young people to start a business.





Related Posts
Diệp Quân
Nguyen Manh Cuong is the author and founder of the vmwareplayerfree blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.
SHARE

Related Posts

Subscribe to get free updates

Post a Comment

Sticky