-

Note: You are currently viewing documentation for Moodle 3.10. Up-to-date documentation for the latest stable version of Moodle may be available here: Localhost.

Localhost: Difference between revisions

From MoodleDocs
(→‎Using a localhost on an internal network: More than anyone wants to know but Great job Tim)
(→‎Using a localhost on an internal network: Given Tim's explaination, changed this a bit)
Line 10: Line 10:
After installing one of Moodle's [[Complete install packages for Windows]] on a Windows machine, the  user is instructed to open up a web browser and type "localhost" in the address bar.
After installing one of Moodle's [[Complete install packages for Windows]] on a Windows machine, the  user is instructed to open up a web browser and type "localhost" in the address bar.


==Using a localhost on an internal network==
==Using a complete install package on an internal network==
A localhost webserver sometimes can be seen by other computers on the same network.   
By changing a few lines of code in a few files, a "localhost" (one computer) webserver sometimes can be changed to be seen by other computers. Generally speaking, this should only be attempted on an internal (where computers share a single router) network.   


For example, a teacher might have one computer in the classroom initially set up as a localhost with a Moodle on it.  The 5 other computers students use as workstations can see that Moodle if they are on the same network. The students need to know the Moodle computer's network IP address and type that in their address bar of their browser.  However, students will not be able to use it from home.
For example, a teacher might have one computer in the classroom initially set up as a localhost with a Moodle on it.  The 5 other computers students use as workstations can see that Moodle if they are on the same network. The students need to know the Moodle computer's network IP address and type that in their address bar of their browser.  However, students will not be able to use it from home.


==Description of IPs and networks==
==Description of IPs and networks==

Revision as of 16:25, 2 February 2009

A localhost means "this computer" in a network. In Moodle documentation, a localhost refers to a web server with Moodle, which is installed on a computer that is not connected to the internet.

In [techie] talk   
  " A localhost is a Internet Protocol loopback device which can be used by 
    TCP/IP applications  to talk to themselves."

The default internal loop IP for the localhost is usually 127.0.0.1 . This IP is different from the IP that identifies the computer on the network.

Localhost example

After installing one of Moodle's Complete install packages for Windows on a Windows machine, the user is instructed to open up a web browser and type "localhost" in the address bar.

Using a complete install package on an internal network

By changing a few lines of code in a few files, a "localhost" (one computer) webserver sometimes can be changed to be seen by other computers. Generally speaking, this should only be attempted on an internal (where computers share a single router) network.

For example, a teacher might have one computer in the classroom initially set up as a localhost with a Moodle on it. The 5 other computers students use as workstations can see that Moodle if they are on the same network. The students need to know the Moodle computer's network IP address and type that in their address bar of their browser. However, students will not be able to use it from home.

Description of IPs and networks

To really understand what is going on, you need to understand a bit about how the internet works. This will be a over simplification but should be useful to some who want the general idea.

Every computer on the internet has a unique IP address, which is a string of 4 numbers. For example, The Moodle.org server computer is 74.52.44.50. To get data from moodle.org, your computer needs to connect to that address. Similarly, your computer will have an IP address, which the server will use to send the data you ask for back to you.

Now typing numbers all the time into the address bar of your browser is a pain in the neck, which is why we have the domain name system (DNS). DNS is simply a lookup service on one or more computers somewhere, that allows you to ask for http://moodle.org/ instead of having to remember things like http://74.52.44.50/. A DNS does the translation for you from the alias "moodle.org" to the IP address.

In addition to every computer having a real address like 74.52.44.50, the IP address standard defines some addresses that are reserved for special use. The IP address 127.0.0.1 is the most useful. No matter which computer you are on, 127.0.0.1 means 'this computer'. In the DNS system, "localhost" is an alias for 127.0.0.1. Localhost is easier to type and so that is what we use.

So, if you are accessing your complete install package Moodle site with a URL in the browser address like http://localhost/moodle/, it will only work on your own computer.

There are some ways to allow other computers to find your Moodle site on your computer. You will need to find the real address of your computer, for example 123.234.345.456. On your computer you could put http://123.234.345.456/moodle/ in the browser address and get to your Moodle site. Now you will need to change some code in a couple of files (update wwwroot address line in config.php). Now other computers might be able to type http://123.234.345.456/moodle/. "Might" because this is a very simple version.

Remember we said 'Every computer on the internet has a unique* IP address', we lied. It is "a bit" more complicated than that. For example, if you have a home network with several computers connected to a router, they should be able to reach your Moodle site my changing the config.php file. It gets tricky when a computer is not directly connected to your home router. Consider that as far as the internet is concerned, it will appear as if there is just one computer (the router) with a single IP address attached to the internet. The router does some magic (called Network Address Translation - NAT) to make all your computers seem like one to the internet. This is helpful because with those IP numbers there can only be 4 billion IP address and there are certainly more computers and routers and things that need IP addresses in the world. Your home router using NAT pretends it is one computer for the internet but it knows which computer sent and should get the returning message/image/data/video. That is the general theory, very oversimplified of how a network works.

Most network experts would not recommend using a personal computer as a internet accessible Moodle site server. If you are behind a NAT router, then getting an address for your computer that can be seen by the internet is harder. Not impossible but it will require some technical network administrator's (maybe more than one network and administrator) cooperation. We should add that a computer that can be seen by the internet is subject to potential bad things from the internet. Also, if you are behind a firewall (a device to prevent bad things), people may not be able to get to your Moodle, even if they know the address. In short, all things are possible but that does not make it easy or desirable.

Localhosts are great for testing things or building courses for later upload to an more secure Moodle site that can be seen from the web. It is possible to install a complete install package on your personal computer and make it available to others on a small network, such as a classroom. Most personal computers that have a complete install package (with its webserver) will not be configured to be visible from the internet.

See also