What is WordPress? At its core, WordPress is the simplest, most popular way to create a website or blog. In fact, WordPress powers over 35.2% of all the websites on the Internet. Yes — one of the three websites that you visit is likely powered by WordPress.
In this article, I’ll show you how to install WordPress on localhost in 5 easy steps. Let’s start with some basic questions.
Why Install WordPress Locally?
Whether you are a beginner or an expert web developer or want to learn more about WordPress. Installing WordPress locally benefits for all. Let’s discuss in details all the benefits of it:
- Get to know WordPress — If you are a beginner to WordPress and want to check or test its functionality. It’s a good way to get to know the WordPress script. You can tinker with it, learn all the functions before finalizing for your final website. This saves you from crashing your live website, also it does not need you to spend any money.
- Flexibility in testing as a developer — If you are a developer, installing WordPress locally helps you in many ways. Safely test or upgrade your plugins and themes. Troubleshooting your code for bugs. No server delays in editing your website. A local version of WordPress is the perfect environment for developers.
- Speed — Locally installed WordPress runs quicker as compared to a shared hosting server. In the case of localhost, data loads from your computer. But for the hosting server, the data is stored somewhere else therefore it takes a bit of time to open. So locally installed WordPress runs faster.
- Offline access — There are some areas where internet reception is not good. Or you are traveling someplace where you do not have access to the internet. In this kind of situation, a locally installed WordPress will save you time. Locally installed WordPress does not need an internet connection to run. It requires only in case you want to download a plugin or theme from WordPress.org repository.
- Compatibility Issues — Some themes and plugins don’t work simultaneously. If activated together they create a compatibility issue. Check locally the compatibility and keep your live website safe from crashing.
- No downtime — Changing theme or installing a plugin might cause an issue on your website. You cannot afford this to happen on a live website. It makes a bad impression on your website reputation and causes a loss of visitors. Installing WordPress locally helps you to prevent this from happening. Make all the changes locally and update on live site once it’s working 100%.
- Security — Testing new code might break your website and it makes your website vulnerable to hackers. But installed WordPress on localhost is only accessible by you. So, it’s the best practice to follow to make your website secure from hackers and attackers.
- Privacy — While developing a website for your clients. There are some situations when the client stole your design and ran off. Keeping your WordPress locally helps you to prevent from this kind of situation.
- Saving cost — Building a WordPress website from scratch takes time. Also, you will need a hosting server and domain name to set-up your website. But installing WordPress locally helps you save months of server bills. Create your website on localhost and once your website is ready, it only requires an internet connection and 15mins time to upload your website content on the hosting server.
Updating your codes, theme or plugin on your live website saves time. But being an experienced WordPress user I confess you, it is so risky. There is always a chance that upgrading to a new version of WordPress, or updating a theme or plugin, will crash your website. Making changes on your locally installed WordPress takes a bit more time but it saves you from all the issues that I mentioned above.
Requirements to Install WordPress
To install WordPress on your computer, you should have these things/functions installed on your computer.
- PHP (Version 7.3 or greater)
- Database (MySQL version 5.6 or greater OR MariaDB version 10.1 or greater)
- Server (Apache or Nginx)
- HTTP or HTTPS
There are some software available for MacOS which provides these features. Here is a list of some of them: XAMPP, MAMP, ServerPress & Local by Flywheel. But today we will be focusing on XAMPP. It provides all the features that are required to install WordPress. It is very easy to use software which includes many other features as well. Also, it is a multi-platform software. You can use it on MacOS, Windows, and Linux. Learning XAMPP will help you to work on other platforms as well.
What is XAMPP?
XAMPP is an open-source software developed by Apache Friends. It is completely free, easy to install and easy to use software. It provides you complete PHP development environment. Let’s understand with its full form.
- X — Cross-platform software. It supports multi-platform installation. You can use it on Windows, MacOS & Linux.
- A — Apache Server. It’s the most widely used web server. It runs almost 2/3rd of the world websites.
- M — MariaDB. Oracle purchased MySQL and they provided an open-source database software called MariaDB. It is a smaller version of MySQL.
- P — PHP. It is a server-side scripting language used to develop static and dynamic websites.
- P — Perl. It is a programming language which is used to develop web application like MetaCPAN, Bugzilla, etc.
In this article, we will be using localhost or locally or offline server many times. All of this means hosting your website on your computer. And Apache Server is the one that helps to host your website locally.
XAMPP contains all the functions that WordPress requires. So I’ll be installing XAMPP to host WordPress website from the home computer.
How to Install WordPress on XAMPP on MacOS
Installing WordPress on XAMPP requires 5 easy steps. Without further due, let’s get started with our installation guide.
Step 1 — Download XAMPP
Visit the Apache Friends website to download XAMPP for MacOS. Follow the link to download page: https://www.apachefriends.org/index.html. After you go to the Apache Friends website. You have to download the file based on your operating system. Since this article is about installing XAMPP in MacOS, so you need to download the file named as XAMPP for OS X. It is also shown in the image.
In case you are using a Windows operating system, I have created a separate guide for that. You can check it here:- How to Download and Install WordPress on XAMPP on Windows
Step 2 — Install XAMPP
Once file finishes download. Go to the Download folder and open the file. Drag and Drop the XAMPP icon to the Application folder to be able to access for later use. Then click on the XAMPP icon, to start the setup procedure.
It will ask your permission to open the file. Click on Open
It will ask for administrator Username and Password. You need to enter login details of your computer. After you enter the details click on OK
Step 3 — Setup XAMPP for WordPress installation
After you finish installing. It will open up this main page of the app. To start the XAMPP services, click on Start
After you click on Start, it will turn that Red light to Green. And it will show an IP address below it. This is the IP address that you can use to open your website after completing the XAMPP setup.
Go to the Services tab. Click on Start All. It will start FTP, Apache and MySQL services. To start your localhost server, you have to Start All services, then only your website will start working.
Go to the next tab called as Network to enable ports for localhost. Enable it by clicking on localhost:8080 -> 80 (Over SSH) and click Enable
Now its time to assign space to your website. Click on Volumes tab, then click on Mount.
After you click on Mount, it will look like this. This confirms that you have successfully mounted space for XAMPP.
After configuration XAMPP, open Chrome or Safari and use this URL: http://localhost:8080 to check if your localhost server is working. If it works, it will open the home page to apache like this. Hurray!!! You have successfully created a localhost server. Now its time to setup a database. To access database creation page, click on phpMyAdmin on the upper right corner on this page or you can go to URL: http://localhost:8080/phpmyadmin
To create a database for WordPress, click on Databases.
Note: The information that I highlighted on the right side, is your Database server details. Take a note of this information, It will be required at the time of WordPress installation.
Enter the database name that you want for your WordPress. In this case, I’m using WordPress for my database name, then click on Create.
Step 4 — Download WordPress
Since the setup of XAMPP is done. Now its time to download WordPress. To download WordPress, go to the WordPress repository website and download the latest WordPress file. Follow this URL to go to the WordPress download page: https://wordpress.org/. After visiting this page, click on Get WordPress.
Click on Download WordPress to start downloading the WordPress script file.
Step 5 — Install WordPress
Open and extract the WordPress file that you just downloaded on this path:- /Applications/XAMPP/htdocs OR 192.168.64.2\lampp\htdocs\wordpress. Both the folder path are same.
After you extract files, open Chrome or Safari and enter the URL: http://localhost:8080/wordpress. It will start the setup process of WordPress.
Select the language for your WordPress and click on Continue.
To proceed with WordPress setup, Click on Let’s go.
Enter the server and database information that we have noted in the previous step.
Database Name: wordpress
Password: -leave it blank-
Database Host: localhost
Table Prefix: wp_
After filling up the information, click on Submit.
After you click on submit, it will give you an error stating “Sorry, but I can’t write the wp-config.php file.” I want to pause you here and want you to go to WordPress folder:- 192.168.64.2\lampp\htdocs\wordpress.
You have to go back to the WordPress folder where you extracted files. You will find a file named as wp-config-sample.php. Rename this file to wp-config.php. Open it in a text editor like Notes, Atom, Sublime, etc. Delete all the content inside this file. Copy all the content mentioned by WordPress setup and pasted it into wp-config.php file.
Once you pasted the code in wp-config.php file. Save the file and close it.
Open Chrome and click on Run the installation.
Enter your website information.
Site Title: Your website name
Username: This is your website administrator username
Password: Enter the password you want to keep for you administrator account
Your Email: Enter your email accounts
Search Engine Visibility: You can leave this unchecked. This setting can also be changed in the WordPress dashboard.
After you fill all the information, click on Install WordPress
WordPress installation is complete. Now you can log-in to your dashboard.
Keep a note of important URL’s:
Website home page: http://localhost:8080/wordpress
To access your WordPress website in the future, you need to open XAMPP and you have to Start All services.
Congratulation!!! You have successfully installed WordPress using XAMPP.
Some applications like Skype use port 80, same as Apache. You check for online help to change to a different port. Or only use one application at a time to avoid this conflict.
If you having any trouble while installing or any other issue related to WordPress or XAMPP, please leave a comment below. I’ll definitely help you with it.