What is localhost?

Localhost refers to the local computer that a program is running on. For example, if you are running a Web browser on your computer, your computer is considered to be the localhost. While this does not need to be specified when using a single computer, the localhost does need to be defined when running programs from multiple computers. For example, a network administrator might use his local machine to start a Web server on one system and use a remote access program on another. These programs would run from computers other than the localhost.

In the example above, the two non-local computers must be defined by their IP addresses. The local machine is defined as localhost, which gives it an IP address of 127.0.0.1. This is considered a loopback address because the information sent to it is routed back to the local machine. Localhost is often used in Web scripting languages like PHP and ASP when defining what server the code should run from or where a database is located.

How to create web server on localhost?

To create a web server you need to install the following:

  • Apache Webserver
  • MYSQL
  • PHP Engine
  • PhpMyAdmin

Apache webserver is the things that runs your dynamic website; You'll need MYSQL if your website keeps data/record in database; PHP Engine lets you run PHP scripts on your webserver; PhpMyAdmin interact with MYSQL so you can update your database records.

In respect of the localhost option there are a number of ready made packages that put all the necessary software together in one easily installable package that generally allow you to have your own personal Web server and database without really knowing too much about how they work.

The following are the more readily available, and popular, varieties of these packages and the operating systems for which they are designed. 

The AMP elements within the following package names stand for Apache, MySQL, and PHP.