Before publishing a web application, you’ve to set it up on a localhost (local host) in order to test and develop it. Especially if you’re coding in PHP, you’ve probably heard about localhost services such as XAMPP and Wampserver. In this article, I’ll teach you what is localhost and how to setup it.
Table of Contents
What is localhost?
In simple terms, localhost refers to the current device or computer you are using. It’s a special hostname that points back to your own machine. When you use localhost in a web browser or any other application, it means you are referring to the software or server running on your computer itself, rather than accessing it over the internet or a network.
So we know what is localhost, but how do we actually use it?
How to set up a Local Host?
There’re some alternatives you can choose from. You might want to install Wampserver and XAMPP or you can just set up a Node.js server from your machine.
I have to clarify something though, local host programs such as Wampserver and XAMPP are built to run PHP. So if you want to build a Ruby on Rails application, it’d make no sense to install those. However, I want to explain how to install them:
1. Installing Wampserver
- Go to https://www.wampserver.com/en/
- Download the latest version of WampServer. Make sure to choose the correct version that matches your operating system (32-bit or 64-bit).
- Once the download is complete, locate the downloaded installer file (usually named something like
"wampserver(version)_x64.exe" for 64-bit systems or "wampserver(version)_x86.exe"
for 32-bit systems). Double-click on the file to run the installer. - The installer will prompt you to select the language for the installation process. Choose your preferred language and click “OK.”
- You will be presented with the WampServer license agreement. Read through it, and if you agree to the terms, click on the “I accept the agreement” checkbox and click “Next.”
- Next, you will be asked to select the destination folder where WampServer will be installed. The default location is usually fine, but you can change it if you prefer. Click “Next” to proceed.
- Choose the folder name where the WampServer program shortcuts will be placed in the Start Menu. You can keep the default name or enter a new one. Click “Next.”
- This step allows you to select additional tasks to be performed during the installation. The options include creating a desktop icon and starting WampServer after installation. Select the options you want and click “Next.”
- Now, the installer is ready to install WampServer on your computer. Click on the “Install” button to begin the installation process.
- During the installation, Windows may display a security warning asking for permission to allow the installer to make changes to your device. Click “Yes” to proceed.
- Finally, you will see a completion message indicating that the installation was successful. Click “Finish” to exit the setup.

2. Installing Node.js and Starting a Local Server
If you don’t have Node.js installed, you need to download and install it from the official Node.js website (https://nodejs.org). Choose the appropriate version for your operating system and follow the installation instructions.
Next, create a new folder on your computer where you want to set up your Node.js project.
Then run the following command:
npm init
This command will guide you through creating a package.json
file, which contains information about your project and its dependencies.
Then we gotta install Express.js. Express is a popular web framework for Node.js that simplifies building web applications. You can install it using the following command:
npm install express
In your project folder, create a new file (e.g main.js
) where you will write your Node.js server code.
As the next step, we have to write our server code. Open the file main.js with your favorite text editor and start coding:
const express = require('express'); const app = express(); const port = 3000; // You can choose any available port number // Define a route app.get('/', (req, res) => { res.send('Hello, this is your localhost server!'); }); // Start the server app.listen(port, () => { console.log(`Server is running at http://localhost:${port}`); });
In your command-line interface, navigate to your project folder (if you’re not already there) and run the following command to start the server:
node server.js
If you see a console message that contains Server is running at http://localhost:3000
or whatever port you’ve chosen, everything works flawlessly.
Visit http://localhost:3000 in your browser and it’s done!
Conclusion
In this article, I tried to teach you what is localhost and how to set up a local host via different methods. Hope you enjoyed it!
1 thought on “What is localhost? Setting up a localhost”