javascript和JQuery焦点图和代码特效大全
当前最流行的开源CMS网站系统大全
当前位置:主页 > 操作系统 > Linux/Unix >

Linux下Apache如何绑定多个域名

来源:IT技术网编辑:hdm58发布于:2011-02-24人围观Linux域名Apache

Linux下Apache如何绑定域名到不同目录的。

例如:VPS的IP是94.249.188.58,需要将wuleilei.com绑定到/var/www/html/dir1,将wuleilei.net绑定到/var/www/html/dir2。

打开http.conf:

1、将#ServerName www.example.com:80修改成ServerName 94.249.188.58:80,注意别忘记了将句首的#去掉;

2、将#NameVirtualHost *:80修改成NameVirtualHost 94.249.188.58:80,注意别忘记了将句首的#去掉;

3、在文件最后面有虚拟主机格式:

[shell]代码:

#  
#    ServerAdmin webmaster@dummy-host.example.com  
#    DocumentRoot /www/docs/dummy-host.example.com  
#    ServerName dummy-host.example.com  
#    ErrorLog logs/dummy-host.example.com-error_log  
#    CustomLog logs/dummy-host.example.com-access_log common  
#  
在后面添加:

[shell]代码:

*IP访问/var/www/html/dir目录

    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/dir
    ServerName 94.249.188.58  
    ErrorLog logs/dummy-host.example.com-error_log  
    CustomLog logs/dummy-host.example.com-access_log common   *wuleilei.com与www.wuleilei.com访问/var/www/html/dir1目录
  
    ServerAdmin webmaster@dummy-host.example.com 
    DocumentRoot /var/www/html/dir1  
    ServerName wuleilei.com  
    ServerAlias www.wuleilei.com  
    ErrorLog logs/dummy-host.example.com-error_log  
    CustomLog logs/dummy-host.example.com-access_log common    
*wuleilei.net与www.wuleilei.net访问/var/www/html/dir2目录
  
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/dir2
    ServerName wuleilei.net 
    ServerAlias www.wuleilei.net
    ErrorLog logs/dummy-host.example.com-error_log  
    CustomLog logs/dummy-host.example.com-access_log common    

 附:如果想开其他端口,请按照如下操作(以8080端口为例):

1、打开http.conf,查找Listen 80,在下面一行添加Listen 8080;

2、在文件末尾添加如下代码:

[shell]代码:

  
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/dir3  
    ServerName wuleilei.com
    ServerAlias www.wuleilei.com
    ErrorLog logs/dummy-host.example.com-error_log  
    CustomLog logs/dummy-host.example.com-access_log common    

Linux,域名,Apache,相关的文章
有时间的话来看看IT界的突发事件