【转】Ubuntu+apache绑定多个域名

1. 将 http://www.a.com 与 http://www.b.com 的DNS解析到你的服务器IP上。

2. 删除apache的默认主机配置文件。你也不希望创建2个虚拟主机后人家还能直接访问/var/www/ 吧 ;
进入 /etc/apache2/sites-enabled/ ; 删除 000-default 文件。

3. 在 /etc/apache2/sites-enabled/ 目录 , 用VI创建2个文件。文件名用 www.a.com.conf ; www.b.com.conf
在 www.a.com.conf 里填入以下代码:

 1 <VirtualHost *:80>
 2         ServerName www.a.com
 3    ServerAdmin webmaster@localhost
 4    DocumentRoot /var/www/www.a.com
 5    <Directory />
 6       Options FollowSymLinks
 7       AllowOverride None
 8    </Directory>
 9    <Directory /var/www/www.a.com/>
10       Options Indexes FollowSymLinks MultiViews
11       AllowOverride None
12       Order allow,deny
13       allow from all
14    </Directory>
15 
16    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
17    <Directory "/usr/lib/cgi-bin">
18       AllowOverride None
19       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
20       Order allow,deny
21       Allow from all
22    </Directory>
23 
24    #ErrorLog ${APACHE_LOG_DIR}/error.log
25 
26    # Possible values include: debug, info, notice, warn, error, crit,
27    # alert, emerg.
28    LogLevel warn
29 
30    #CustomLog ${APACHE_LOG_DIR}/access.log combined
31 
32     Alias /doc/ "/usr/share/doc/"
33     <Directory "/usr/share/doc/">
34         Options Indexes MultiViews FollowSymLinks
35         AllowOverride None
36         Order deny,allow
37         Deny from all
38         Allow from 127.0.0.0/255.0.0.0 ::1/128
39     </Directory>
40 
41 </VirtualHost>
www.a.com.conf
 1 <VirtualHost *:80>
 2         ServerName www.b.com
 3    ServerAdmin webmaster@localhost
 4    DocumentRoot /var/www/www.b.com
 5    <Directory />
 6       Options FollowSymLinks
 7       AllowOverride None
 8    </Directory>
 9    <Directory /var/www/www.b.com/>
10       Options Indexes FollowSymLinks MultiViews
11       AllowOverride None
12       Order allow,deny
13       allow from all
14    </Directory>
15 
16    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
17    <Directory "/usr/lib/cgi-bin">
18       AllowOverride None
19       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
20       Order allow,deny
21       Allow from all
22    </Directory>
23 
24    #ErrorLog ${APACHE_LOG_DIR}/error.log
25 
26    # Possible values include: debug, info, notice, warn, error, crit,
27    # alert, emerg.
28    LogLevel warn
29 
30    #CustomLog ${APACHE_LOG_DIR}/access.log combined
31 
32     Alias /doc/ "/usr/share/doc/"
33     <Directory "/usr/share/doc/">
34         Options Indexes MultiViews FollowSymLinks
35         AllowOverride None
36         Order deny,allow
37         Deny from all
38         Allow from 127.0.0.0/255.0.0.0 ::1/128
39     </Directory>
40 
41 </VirtualHost>
www.b.com.conf

apache详细权限在以上配置文件修改就行。

 

文章转自:http://forum.ubuntu.org.cn/viewtopic.php?t=341070

转载于:https://www.cnblogs.com/A--Q/p/6741706.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值