单位有台老机器,为了跑一些web服务,拿来做php服务器。

选用了FreeBSD 5.4,nginx和php(电脑的配置是:p3 667, 256 MB memory, 40 GB HardDisk……p o_o r)

安装过程一波三折 继续阅读 »

 

上一次,讲述了IP地址、DNS以及网络如何引导别人访问你的域名。这一次来说说服务器、端口、WEB服务、HTTP协议、脚本语言、存储等。

现在已经知道,输入 http://blog.liuzhy.com 就可以到达我的博客,但是,是什么告诉浏览器该如何显示这些网页?又是什么把我今天写的字保存了下来,供需要的人以后查看呢?

仔细想想,这是个没有魔法的世界,你输入blog.liuzhy.com,然后由网络把它变成一个IP地址,于是你的浏览器顺着那个IP门牌号,找到了我的服务器上,对,就是它,躺在美国bluehost机房的这台电脑……浏览器非常聪明的找到了这台电脑的80端口,然后开始建立连接,对这台电脑说:HELLO,我来看你了…… 电脑回复道:OH, 我的朋友,给你这个网页,让他看去吧……等等,什么是80端口?浏览器和电脑通话用的是英语?法语?中文?

一台连上网的电脑,一般情况会运行很多和网络有关的程序,比如你的ICQ,MSN,IE 或者 Firefox,在线视频,在线游戏……甚至赖以赚钱的股票软件,还有好多你看不到的东西,偷偷摸摸的访问着互联网,时不时跳出来吓你一跳“我该升级了”。你也许会想,这么多的应用程序,但是你的电脑只有一个IP地址,他们彼此之间是怎么互相区分呢?比如服务器给你的电脑发了一条消息,这条消息是发给MSN的?发给IE的?还是发给股票软件的?

不仅是我们在困扰,最开始的时候,设计网络的人也在困扰……于是一个新名词就诞生了:端口。一个IP地址对应的电脑,通常情况被划分了65536个端口,用来区分不同的软件应用。而且有很多端口已经约定俗成了。比如,我的服务器向互联网上的所有人提供网页服务,那么通常情况,你的浏览器就要访问我的80号端口,如果服务器提供FTP电影下载,那么通常情况你的下载软件要访问我的21号端口。所以,对于当前的情况,一个完整的表示地址应该是IP加端口的格式,例如:xxx.xx.xx.xxx:80,前面是IP地址,后面就是端口号。当你的ICQ连到服务器上时,你的电脑中某个端口已经被这个软件占用了,别的软件再用,只能“对不起,请你换个端口吧”。

有了端口的概念,那么你的浏览器就要正式访问我的web服务了,于是浏览器对着liuzhy.com:80说: HTTP 1.1/ request xxxxxx,浏览器正式回应:HTTP 1.1/ reponsexxxxxxxxx。而且每次请求与回复,都是类似这样的格式。这就是所谓的HTTP协议,也就是浏览器能正确解释WEB语言的基础,因为HTTP协议是所有WEB访问都要遵守的重要协议之一。如果浏览器发出了HTTP 协议请求”Hello, I am HTTP”,得到的却是另外的协议”Sorry, I am PTTH”,于是浏览器就会告诉你:该网站不可用,因为他没有正确提供HTTP协议响应。

呃 要工作了。关于脚本和数据存储,只好有机会再写了。

 

English Version:

This is lesson 1: IP and Domain name. That means: how a navigator like IE or FireFox know where is news.google.com, www.yahoo.com or yourdamain.com(like liuzhy.com, ;-) ).

As you knows: you can visit my blog, you are connecting to INTERNET.  No matter what you are using: wire or wireless.

Like a person in society, every one need a ID, this ID will never as the same to others, if it happened, maybe you or him will be troubled, and a department will solve it quickly. Internet is similar. Each device connected to it must have an ONLY ID named IP address. Each device means: Mobile phone,  Notebook, Mac, Wii, and even a router(it’s a box with cables). Here is a question, if you visit my blog in your company or a net cafe, that’s diff. you can check your IP, it should like 10.x.x.x or 192.168.x.x, that’s not your real IP, when you connect to a website,it will know you real IP in internet. Is it diffcult to undersand? take it easy, what’s you should know is: an ONLY IP is needed if you connect to internte.

OK, Next is domain name. it is easy to understand: like google.com, vol.com and a famous website: liuzhy.com,ha..If you type it in your navigator’s address bar and Enter, a page will be shown. but… wait, the google.com must had a server machine(s) to service you, it is a device in internet, it must have a IP. How a domain to a IP? because there are lots of devices named DNS server to solve it.

Now, let’s visite google.com more one time: you type “www.google.com” and enter. What’s the navigator doing is look for “google.com” ‘s IP address, so it send a request to the closest DNS server. and the DNS server reponse: google.com = xx.xx.xx.xx, now navigator navigate to xx.xx.xx.xx. So you open the page and happy to search anything.

Of cause, this ia luck. In most cases, you type “blog.liuzhy.com” and your closest DNS server don’t know that’s the IP, so “liuzhy.com=?” message will be sent from this DNS to another and to another until a DNS server knows. Are these DNS servers is fool? no, there’s a set of rules to guarantee spending a little time, that’s no need to know.

That’s how IP and domain name and DNS works. If you buy a domain name and make it to your own IP:xx.xx.xx.xx, you should waiting for 2 to 24 hours until every DNS server know “yourdomain = xx.xx.xx.xx”. Before it, you can visit your website by using xx.xx.xx.xx. If it’s still invalid, you should check you internet connection, your website IP, your script error, or even a security reason(in some area, numbers of IP was banned..hnnn). If you don’t know this, you can post your problem here, I would try to help you.

That’s the lesson 1, easy to know.

中文版本:

今天,我想主要介绍的是IP地址和域名。也就是说:当你输入news.google.com或者www.yahoo.com的时候,你的浏览器是如何找到这个网站并实现一些功能(比如看新闻,登录论坛,搜索等)。

众所周知,我们的电脑是通过种种方式连接到互联网上的,无论是网线、光纤或者是电话线、蓝牙、无线网络等等,既然你能看到我的博客,说明你能连接到互联网。

就像人在社会上活动一样,我们需要名字和身份证号,很多人都叫张三李四,但是身份证号是不应该有相同的,如果有两个人的身份证号相同了……呃,会有相应的机构来处理这件事儿。互联网上的各种设备也是一样,无论是你的电脑或者是大型网站的服务器甚至是为电脑指路的设备,都是有身份证号的,这就是IP地址。理论上,互联网上的ip地址是不应该有重合的,但是有时候,一个IP可能被多人所用,比如在网吧或者是公司。这时候,就有相应的设备去区分互联网与公司(网吧)内部IP,这个无需过问。因为当你通过网吧访问google的时候,google只会针对那个接入互联网IP,而不是你机器的IP……或许有些拗口,但是这无关紧要,你只要记住,当你能上网的时候,一定有一个在互联网上是唯一的IP作为你访问的标识,也就是你的身份证。

同样,百度或者新浪或者淘宝,既然你能够访问到他们,说明……他们也一定有IP身份证。但是IP身份证很复杂,是一连串的数字,为什么你不用记住这串数字而只要输入:baidu.com、sina.com.cn、 taobao.com(这些叫做域名)就能看到网页呢?其实很简单。网络中间有很多用来把baidu.com 和它的IP对应的设备,这些设备学名叫做DNS。当你在浏览器中输入:baidu.com的时候,你的电脑并不知道这是哪里,于是它就向离它最近的DNS询问:baidu.com是哪里啊?如果幸运的话,这个DNS会告诉你的浏览器是xx.xx.xx.xx(IP地址),你的浏览器就会直接连到那里,打开网页准备等待你的下一步动作;但是大多数时候是不幸的,离你最近的DNS是乡村DNS,他并不知道baidu.com在哪里,于是它又会向另外一个它觉得比较靠谱的DNS询问:你知道baidu.com在哪里吗?……以此类推,总有一个DNS会知道,于是一传十十传百,你的浏览器也会知道。当然,在第二种情况里,DNS会根据一些规则,向特定的其他DNS来询问,而不是胡乱询问,不然……会很浪费时间。

这就是IP和域名是如何统一起来的。对应到建立网站上面,就是:你申请了域名liuzhy.com,并把它对应到了xx.xx.xx.xx这个IP地址……但是你用浏览器一打开:找不到网站。这并不是什么令人害怕的问题,你需要等等,等管理liuzhy.com域名的DNS告诉其余的DNS:liuzhy.com是归我管的。这个过程,往往需要2-24小时。再此之前,你可以使用IP地址来访问你的网站。如果,连IP地址都不能访问的话 – 就需要找原因了:或许你并没有打开你的adsl,或许你们国家的防火墙认为你的IP不安全,或许……当然,如果你遇到了这类问题,可以在后面问我,会尽量帮助你解决它。谢谢,第一课结束了。

 

English version:

After my Bluehost puraching, I record it here.

Long time ago, I decided to create a website on Bluehost, and my wife often tell me: Others’ website is more and more beautiful, what are you doing everyday?

So…I searched for a lower price of Bluehost. And one day, Google tell me “bluehost 3.95″. ^_^

I spent about $140 for 3 years hosting. and the “liuzhy.com” was borned.

but unfortunately, a famous national firewall blocked my server because the shared IP, I can’t visite my dear website.

My poor English was now  useful. I talked to some night shift staff (? I mean who work in night..), they give me a highway to the aim: They would NOT change anogher server for me, I should buy a dedicated IP to solve the problem.

Poor English, make my wallet empty, so $89 gone……and then…

One told me: your account was not verified, so you cant purache for dedicated IP.

when I was busy in account verifing, another told me: I can give you the dedicated IP, but can’t help your verifing…….

At last, liuzhy.com can be visited from mainland china.

sorry for my poor English. thanks.

中文版:

购买了bluehost的空间。下面简单谈下Bluehost的购买流程。

想建个站已经很久了,也瞄准了bluehost的空间好久了。

老婆看着别人的网站一天天丰富,一天天漂亮,也催促和若干次。

终于在出差的时候,发现通过某些链接,可以得到每个月$3.95的优惠。(可以通过“bluehost 3.95”这两个关键词进行google)

比以前的6.95便宜了不少,起码一个固定IP的价格出来了。(在英文里叫做dedicated IP)

于是咬牙切齿从信用卡上支付了若干$,购买了bluehost的一个空间,域名就是上面的:liuzhy.com,我的名字。

———–我是故事分割线—————-

不幸从此开始:我被自动分配到了某台服务器,可惜这台服务器的共享IP地址,已经被有关部门封锁了。

于是操着半生不熟的英语,开始和bluehost交涉。遗憾的是,他们无法给我更换服务器,只是一个劲的建议我购买dedicated IP。

通过livechat和ticket都没有结果,郁闷中都要放弃了。

后来想了想,既然开始了,就不要半途而废,于是决定购买个IP地址。

新问题又冒出来,没有经过验证的账户,是无法设置专用IP的。

我又不知道如何验证……

这时候,某位live chat的工作人员帮了我,他说:我可以帮你弄静态IP,但是无法帮你验证。

这和之前另一位live chat的工作人员说法不同。之前我得到的是:你的帐户尚未验证,无法帮你开通静态IP。

看来老美也不是都那么一丝不苟。

终于又花了一些$。于是,我们伟大的祖国就接受了我的小站。以后再被封?以后再说吧。

好事总是历经磨难,或者说……没有什么事是好事吧。

© 2011 文字与技术 原创内容,转载请注明网址 http://liuzhy.com Suffusion theme by Sayontan Sinha