用一个Apache服务器来做多个Web服务器,比如运行几个不同的网站:
1、修改hosts文件(位于%system%\system32\drivers\etc),目的是为了输入域名访问对应的IP
将相应的IP和域名进行映射(如:127.0.0.2 local2.com)
2、配置下面两个文件,即httpd.conf和httpd-vhosts.conf
httpd.conf在apache服务器文件夹的conf里面
httpd-vhosts.conf在conf文件夹的extra里面
修改httpd.conf
把#Include conf/extra/httpd-vhosts.conf前面的#去掉,意思是让httpd.conf文件包含httpd-vhosts.conf这个配置文件,这是apache的配置模块化的一个表现,这里不多说。
修改httpd-vhosts.conf
添加如下代码:
<VirtualHost ip:端口>
DocumentRoot 虚拟主机路径 #如:c:\wamp\www\
ServerName 域名
</VirtualHost>
值得注意的是,VirtualHost是有顺序的,排在最前的VirtualHost的我们默认的网站域名.
Ip,ServerName是在上面hosts文件所配置的配对.
3、为站点添加HTTP端口
用文本编辑器打开apache2/conf文件夹下”httpd.conf”配置文件。
查找Listen,定位到 listen 80处!在此下方添加一个端口行,如(listen 1080),保存文件。
用文本编辑器打开apache2/conf/extra文件夹下”httpd-vhosts.conf”配置文件。
添加一个虚拟主机。如:
<VirtualHost ip:1080>
DocumentRoot document_root #站点物理路径
ServerName tianshi.com #别名
</VirtualHost>
将文件保存,重启apache,在URL地址栏输入ip:1080即可访问.

30 Comments

  1. I just wanted to comment and say that I really enjoyed reading your blog post here. It was very informative and I also digg the way you write! Keep it up and I’ll be back to read more in the future

  2. An interesting dialogue is worth comment. I think that it is best to write extra on this matter, it won’t be a taboo subject but typically individuals are not sufficient to talk on such topics. To the next. Cheers

  3. I’ve really noticed that credit restoration activity really needs to be conducted with techniques. If not, you are going to find yourself destroying your rank. In order to be successful in fixing your credit rating you have to confirm that from this instant you pay your complete monthly costs promptly in advance of their planned date. It is significant since by not necessarily accomplishing that, all other steps that you will choose to use to improve your credit ranking will not be efficient. Thanks for discussing your thoughts.

  4. Thanks for your publication. What I want to say is that when looking for a good on-line electronics shop, look for a web-site with complete information on critical indicators such as the privacy statement, security details, any payment guidelines, and other terms and also policies. Always take time to read the help and FAQ areas to get a far better idea of the way the shop operates, what they can perform for you, and the way you can make the most of the features.

  5. Thank you for sharing most of these wonderful content. In addition, the ideal travel as well as medical insurance strategy can often ease those worries that come with touring abroad. Some sort of medical crisis can quickly become too expensive and that’s likely to quickly impose a financial problem on the family’s finances. Having in place the excellent travel insurance program prior to leaving is definitely worth the time and effort. Cheers

发表评论

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


*