Apache - virtual hosts
2009-05-13 13:21:35来源:未知 阅读 ()
See also
Apache topics
.
If you want to know more about virtual machines, see
http://cybernut.com/guides/virtual.html
Virtual hosts
A web server is both software and hardware. The machine on which the web site resides is referred to as a web server. The software which runs the web site is also referred to as a web server. In our case, Apache (the web server) runs on our FreeBSD box (also, our web server). But a given web server can run more than one web site. It can achieve this multi-use by using virtual hosting.
Virtual hosting is the ability for a website to act as if it is the only web site on the machine. Given that some web site can be idle for long periods of time, allowing many web sites to share the same hardware is a great way to reduce costs.
A
very good explanation
appears within the Apache documentation. For more detail, please refer to that document.
Name-based virtual hosts
For this example, we'll be making use of name-based virtual hosts. Again, the Apache documentation
explains this term
very well. We will also be making use of
their example
.
In this example, I've registered two names both of which translate to my FreeBSD box. For more information on how I actually did this, see
httpd/dns
. The two host names in question are:
- http://freebsddiary.yi.org - no longer in use
http://test.freebsddiary.org
The server machine has one IP address, 192.168.0.45 which resolves to the name test.freebsddiary.org. Here is what I've ensured is in my configuration file (/usr/local/etc/apache/httpd.conf):
NOTE: See the notes after this example.
...
Port 80
ServerName test.freebsddiary.org
NameVirtualHost 192.168.0.45
DocumentRoot /usr/local/www/data/freebsddiary
ServerName
test.freebsddiary.org
ErrorLog /var/log/freebsddiary-error.log
TransferLog /var/log/freebsddiary-access.log
DocumentRoot /usr/local/www/data/freebsddiary.yi.org
ServerName freebsddiary.yi.org
ErrorLog /var/log/freebsddiary.yi.org-error.log
TransferLog /var/log/freebsddiary.yi.org-access.log
DocumentRoot is the location of the html files for the given virtual website.
Newer versions of Apache can use combined logs. Search for CustomLog in your Apache configuration file in order to see if you can use this format instaed. In which case, these entries will be helpful as an example:
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Freebsd oracle 10g 2009-05-13
- KDE/FreeBSD 测试 QT-4.5.1. 2009-05-13
- OpenBSD 4.5下安装Gnome 2.24成功! 2009-05-13
- FAMP5.0推出,网页式管理服务器,一键安装Apache+Nginx+Mysql+ 2009-05-13
- 使用中的Apache2居然无法启动了 2009-05-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash