发布于 2016-02-05 07:07:51 | 168 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Apache Web服务器

Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件。


这篇文章主要介绍了Apache服务器一个IP多个站点的配置方法示例,本文介绍的方法其实就是虚拟主机的方式,需要的朋友可以参考下

在日常的网站发布中很多情况下都无法做到一个IP对应一个站点,在IP4的情况下IP的资源是相对有限的。然而作为最流行的Apache自然也考虑到这种情况,那么接下来看看apache服务器怎么配置一个IP多个站点。

在httpd.conf中找到 "# Virtual hosts",并添加如下行



ServerName 你的域名

HostNameLookups off


例子  


NameVirtualHost 192.168.1.104

<VirtualHost 192.168.1.104>
    ServerName www.php.com
    ServerAdmin test@gmail.com
    DocumentRoot /data/www1/
    DirectoryIndex index.php index.html index.htm index.shtml
    Errorlog /usr/local/apache2/logs/wwwError_log
    Loglevel warn
    HostNameLookups off
    <Directory /data/www1/>
     AllowOverride None
     Order allow,deny
     Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 192.168.1.104>
    ServerName bbs.php.com
    ServerAdmin test@gmail.com
    DocumentRoot /data/www2/
    DirectoryIndex index.php index.html index.htm index.shtml
    Errorlog /usr/local/apache2/logs/bbsError_log
    Loglevel warn
    HostNameLookups off
    <Directory /data/www2/>
     AllowOverride None
     Order allow,deny
     Allow from all
    </Directory>
</VirtualHost>

上述的例子IP都是192.168.1.104,域名分别是www.php.com和bbs.php.com。因而可知apahce是通过ServerName来识别同一个IP下的不同站点的。

  在实际应用中你只需要将IP192.168.1.104、域名www.php.com和bbs.php.com分别改成你的IP和域名即可。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务