LOCALHOST


LOCALHOST THERE IS NO PLACE LIKE 127.0.0.1 

        In Computer networking, localhost is a hostname that refers to the current computer used to access it. It is used to access the network services that are running on the host via the loopback network interface. Using the loopback interface bypasses any local network interface hardware. The localhost is the default name describing the local computer address also known as the loopback address. For example, typing: ping localhost would ping the local IP address of 127.0. 0.1 (the loopback address). When setting up a web server or software on a web server, 127.0.

While developing websites, there are two main locations you are going to be working in.
        The first is your web server. Your web server is the computer that is broadcasting, or 'serving', your web page and it's content to the internet. This is also known as the 'production server', your web host, or your remote host. On your production server, you have your working website that is accessible to all on the internet.
        The second is your local machine. You will rarely want to actively edit files that are on your web server, so it is recommended that you do this on your own machine, without broadcasting all of your changes to the internet. This is commonly called your 'development server', or your localhost.
        However, there is a problem, your personal computer is not a server. If we want to develop and test our sites, we have run a web server locally on our machine, visible only to us.

HOW TO CREAT LOCAL HOST ON YOUR DEVICE.

Option 1 : ON YOUR ANDROID OR ISO DEVICE USING TERMUX :

Open termux on your device and type following commands in your termux.

(1) apt update
(2) apt upgrade
(3) apt install php
(4) apt install nano
(5) cd /sdcard/
(6) ls
(7) cd Web (select your website’s folder)
(8) ls
(9) nano INDEX.html
(10) ctrl+x
(11) php –S localhost:4774 –t /sdcard/Web/
                            OR
(11) Php –S 127.0.0.1:4774 –t /sdcard/Web/

Open your browser and past that link in browser
ex : http://127.0.0.1:4774

NOTE :~ 
if you get error like “cannot open directory ‘.’ : Permission denied”
Then type this command :~
“termux-setup-storage”

For tutorial video on how to make localhost in your termux please click here.
Click here to download web template for practice.

Option 2 : ON YOUR PC USING XAMPP :

1. Download and Install XAMPP :

XAMPP can be downloaded and installed on Mac/Windows/Linux. Download the version for your operating system from the XAMPP Homepage. XAMPP Homepage and Downloads Download to your machine, and install using the install wizards.

2. Steps after installation of XAMPP : 

On Windows:
  1. Open XAMPP and view the Control Panel.
  2. Start Apache by clicking on the Start option of the Apache service
  3. Click Explorer to see the file structure of your localhost server.
  4. Click on the htdocs folder. Our HTML and PHP documents will be located here.
  5. Create a new folder in htdocs, call it my-site
  6. Put your website content in the my-site folder.
  7. Navigate in your web browser to http://localhost/my-site to see your site.
On Mac:
  1. Open XAMPP and click on the "Manage Servers" tab.
  2. Click start on the Apache Server option.
  3. In Finder, go to the XAMPP folder in Applications and open the htdocs folder.
  4. In htdocs, create a new folder named my-site.
  5. Place your website documents and site materials into the my-site folder.
  6. Navigate in your web browser to http://localhost/my-site to see your site.

Post a Comment

0 Comments