473,378 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

accessing web server locally by different ways

194 100+
I have a very basic question about accessing PHP Web Server (apache) locally by different ways. These ways can be:

localhost
127.0.0.1
IP address of the computer
name of the computer


Which option is best and why? Why all these are used? and what is the important of each of them?
Mar 12 '10 #1
3 1668
Atli
5,058 Expert 4TB
Hey.

localhost is just an alias for 127.0.0.1, which is an IP that targets the computer you are on.

The IP address of the computer can vary. It can either be:
  • an internal address (usually in the range 192.168.x.x) which is automatically assigned by a DHCP server (usually a router), or manually set on each computer (not recommended!).
  • and external address, assigned by an ISP.

The name of the computer is also just an alias for an IP address. DNS servers assign domain names to IP addresses (google.com, bytes.com) so that you do not have to enter the entire IP when you want to visit a site. - Routers on internal networks do the same thing. When your computer is assigned an IP on a local network, the name of your computer is registered with the router and assigned to your given IP address. - When somebody on your network types a name in a browser, his/her browser sends a request to the router asking what IP that name represents. If it is a local name (e.g. "john-doe", "me.lan") the router sends back the network IP registered for that name. If it is an external domain (e.g. "google.com", "bytes.com") then the router forwards your request to your ISP's DNS server, which replies with the IP for that domain name.

As to which is best to use, that depends on what you are doing.
  • If you are just connecting to a local service, like a Apache HTTP server on your own computer, using either "localhost" or "127.0.0.1" is fine. They are pretty much equal, so it doesn't really matter which you use. (The IP *may* be slightly better, since it is the OSs responsibility to assign "localhost" to the IP, and certain OSs *cough*Vista*cough* have been known to muck that up.)
  • If you are connecting to a computer on the network, the computer's name may be better than using the network IP, since DHCP servers don't always assign the same IP address to the same device.
  • For external connections, it's generally better to us an IP than a domain name. It removes the need to request the IP from the DNS servers. - The downside to that is that domain names can change locations, and can even be dynamically rotated based on various factors. (For example, when you connect to Facebook, you are not always connecting to the same server. You are often re-routed to a server that is less loaded or geographically closer to you.) - However, if it is a *normal* domain name that statically points to a single IP, fetching the IP once and using that is better than using the domain name itself.

Hope that helps.
Mar 12 '10 #2
Markus
6,050 Expert 4TB
Great answer, Atli :D
Mar 12 '10 #3
mfaisalwarraich
194 100+
very very helpful and excellent reply Atli. thanx alot
Mar 12 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Peter A. Schott | last post by:
Got a strange scenario going on here in that I could have sworn this worked yesterday. I am issuing binary retrieval calls to an FTP server, writing to a file, close the file, then removing the...
2
by: mir nazim | last post by:
hello, i am writing an application and need to access mysql od sqllite from javascript. is it possible to access mysql/sqllite (or any free lightweight relational databse) directly from...
1
by: ehilario | last post by:
Hi Mark, The following shows when I call it locally. If you look at the URL that has http://localhost, this is the one I use when I call the ASP page from the same local server (self...
3
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different...
5
by: Khalique | last post by:
Hi everyone, I Hope that someone will be able to give me a hint to the solution to my problem. I have developed a web service (vb.net) that needs to access the folders / files and copy files to...
0
by: PÃ¥l Eilertsen | last post by:
Hi, I have a ASP.Net application that uses a MS Access database. The site works fine when all databases resides locally but on my public server I need to use a different database where the main...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
29
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. How do I...
5
by: shotokan99 | last post by:
hi, i was given a query string : http://mywebservice.com?url=<xurl where xurl=is a valid url. now what the query string does it will display an xml on the page. like this one: <?xml...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.