You are here: Re: Cannot get mysql_connect to work « PHP Programming Language « IT news, forums, messages
Re: Cannot get mysql_connect to work

Posted by David Haynes on 12/28/05 14:21

Michael wrote:
> Jerry,
>
> Thanks for your help. I guess I'm a little confused about localhost. It
> seems that if I open a file in the browser at
> http:/localhost/myFile.html, it actually refers to the file
> /var/www/html/myFile.html. So it seems there are two meanings to
> localhost? In one context it refers to the local machine via ip
> address 127.0.0.1, and in the context of the browser, (with Apache
> running?), localhost refers to a specifc directory path on the local
> machine. This is why I'm confused. Can you shed any light on this?
>
> Thanks,
> M. McDonnell
> P.S., my /etc/host file looks ok (see below).
> ================/etc/host file ================
> Do not remove the following line, or various programs
> # that require network functionality will fail.
> 127.0.0.1 McDonnell localhost.localdomain localhost
> ==========================================
>
Michael,
The URL http://localhost/myFile.html is composed of a number of sections:
'http:' indicates the protocol to be used (another example would the svn:)
'localhost' (or any fully qualified name) indicates the Internet Address
of the server that browser requests should be sent to. Sometimes there
is also a port associated with the address (e.g. localhost:8000). The
default ports are 80 for http protocol and 443 for https protocol.

The name 'localhost' or 'www.foo.com' is simply an alias for an Internet
address in the form aaa.bbb.ccc.ddd (assuming IPv4). So, your browser
needs to be able to translate www.foo.com into a meaningful
aaa.bbb.ccc.ddd value.

Your system has a file (/etc/hosts) that maps unregistered names (e.g.
localhost) to IP addresses (e.g. 127.0.0.1)

So, by the time your browser is done with it, the URL
http://localhost/myFile.html has been translated to 'use http protocol',
talking to 127.0.0.1 port 80, and ask for the 'myFile.html' file.

Now, your web server has a concept of a document root, that is the
directory where all the web pages and supporting files on kept. On your
system, this is set to /var/www/html. So when the server sees the
browser's request for the file 'myFile.html' is translates this to 'send
back the contents of file '/var/www/html/myFile.html'.

Another thing about IP aliases. You notice that I said 'unregistered
names'. That is because names like 'www.ibm.com' are registered to be
universally (sometimes called globally) unique and are defined in a
world-wide database know as the 'name service'.

If you want to know more about this side of things, check out programs
like 'bind' and files like '/etc/resolv.conf'.

-david-

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация