Apache2多站点配置的例子。

仅供存放个人的配置文件,不要在本版发问。
回复
头像
oneleaf
论坛管理员
帖子: 10446
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Apache2多站点配置的例子。

#1

帖子 oneleaf » 2006-09-18 15:44

安装完毕apache后,不需要修改任何配置文件,包括 httpd.conf 、 httpd.conf 和 apache2.conf 配置文件。

more /etc/apache2/sites-available/site1.xxxx.com

代码: 全选

<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName site1.xxxx.com
        CustomLog  /var/log/apache2/site1.xxxx.com-access.log combined
        DocumentRoot /var/www/site1/
        <Directory /var/www/site1/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>
more /etc/apache2/sites-available/site2.xxxx.com

代码: 全选

<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName site2.xxxx.com
        ServerAlias site2.yyyy.com
        CustomLog  /var/log/apache2/site2.xxxx.com-access.log combined
        DocumentRoot /web/site2
        <Directory /web/site2>
                Options Indexes
                AllowOverride None
                Order allow,deny
                allow from all 
        </Directory>
</VirtualHost>
创建完毕后,直接
sudo ln -s /etc/apache2/sites-available/site1.xxxx.com /etc/apache2/sites-enabled/site1.xxxx.com
sudo ln -s /etc/apache2/sites-available/site2.xxxx.com /etc/apache2/sites-enabled/site2.xxxx.com

重启apache2
sudo /etc/init.d/apache2 force-reload
joeren
帖子: 29
注册时间: 2006-11-21 15:10
来自: 江苏

#2

帖子 joeren » 2006-11-28 8:56

apache2的配置,不需要修改主配置文件apache2.conf吗?
头像
oneleaf
论坛管理员
帖子: 10446
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

#3

帖子 oneleaf » 2006-11-28 11:24

joeren 写了:apache2的配置,不需要修改主配置文件apache2.conf吗?
不需要的。
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#4

帖子 eexpress » 2006-11-28 11:36

这种好。简单。最喜欢ln -s的方式了。
● 鸣学
myub88
帖子: 11
注册时间: 2007-03-03 15:43

#5

帖子 myub88 » 2007-03-05 20:21

这东西不是与linux无关吧?这类例子也没意思,httpd.conf在装好后不是有一个例子么?每行的#号下面都说得很清楚,做什么怎么用清清楚。
feiyuw
帖子: 97
注册时间: 2006-01-03 22:49

#6

帖子 feiyuw » 2007-04-26 9:22

满好的,适合我这种不想看注释的懒人,多谢楼主!
头像
marsteel
帖子: 555
注册时间: 2005-11-28 12:09
联系:

#7

帖子 marsteel » 2007-06-01 16:56

myub88 写了:这东西不是与linux无关吧?这类例子也没意思,httpd.conf在装好后不是有一个例子么?每行的#号下面都说得很清楚,做什么怎么用清清楚。
别这样。。。
头像
hatoyu
帖子: 171
注册时间: 2006-03-16 10:20
来自: http://www.adelaidecartridge.com
联系:

#8

帖子 hatoyu » 2008-06-02 15:58

我的 apache2 安装之后 httpd.conf 是空白的
hlsd665
帖子: 38
注册时间: 2006-12-13 8:20

Re: Apache2多站点配置的例子。

#9

帖子 hlsd665 » 2008-12-26 8:56

oneleaf 写了:安装完毕apache后,不需要修改任何配置文件,包括 httpd.conf 、 httpd.conf 和 apache2.conf 配置文件。

more /etc/apache2/sites-available/site1.xxxx.com

代码: 全选

<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName site1.xxxx.com
        CustomLog  /var/log/apache2/site1.xxxx.com-access.log combined
        DocumentRoot /var/www/site1/
        <Directory /var/www/site1/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>
more /etc/apache2/sites-available/site2.xxxx.com

代码: 全选

<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName site2.xxxx.com
        ServerAlias site2.yyyy.com
        CustomLog  /var/log/apache2/site2.xxxx.com-access.log combined
        DocumentRoot /web/site2
        <Directory /web/site2>
                Options Indexes
                AllowOverride None
                Order allow,deny
                allow from all 
        </Directory>
</VirtualHost>
创建完毕后,直接
sudo ln -s /etc/apache2/sites-available/site1.xxxx.com /etc/apache2/sites-enabled/site1.xxxx.com
sudo ln -s /etc/apache2/sites-available/site2.xxxx.com /etc/apache2/sites-enabled/site2.xxxx.com

重启apache2
sudo /etc/init.d/apache2 force-reload

问一下楼主,这种多站点的配置,访问每个站点时要怎么访问?
“site1.xxxx.com site2.xxxx.com"
是这样吗?
要是再加上动态域名,那动态域名会连到哪个站?这样访问时会访问哪个站?
头像
JarodLee
帖子: 180
注册时间: 2007-09-02 18:54
来自: ghtxx.cn
联系:

Re: Apache2多站点配置的例子。

#10

帖子 JarodLee » 2009-02-02 14:48

有熟悉这个方法的高手在线吗?
我用这个方法配置了个服务器后,把ubuntu从8.04升级到8.10,这个配置似乎无效了,在8.04下两个域名都是独立有效的,可在到8.10就无效了。。。

是什么原因呢,看了sites-enable下的文件,还在,没变动呀。。。。
Life is a gift.
一起到我们的Linux学习MSN群中来吧:加linux@ghtxx.cn为好友讨论。
ttlove
帖子: 3
注册时间: 2008-10-23 22:47

Re: Apache2多站点配置的例子。

#11

帖子 ttlove » 2009-10-25 3:11

:em06 9.04用这个也无效。。。我倒!
回复