apache下多站點的架設(shè)
apache 下多站點的架設(shè)核心提示:這里是指同一IP 綁定N 個域名,有二種方式實現(xiàn) 方法1、僅修改httpd.conf 假設(shè)二個域名bbs.xxx.com 與blog.xxx.com 打開http
apache 下多站點的架設(shè)
核心提示:這里是指同一IP 綁定N 個域名,有二種方式實現(xiàn) 方法1、僅修改httpd.conf 假設(shè)二個域名bbs.xxx.com 與blog.xxx.com 打開httpd.conf 將文件拖到最下面,加上 VirtualHost *:80 ServerNamebbs.xxx.com#域名 DocumentRootF:/website/bbs#該域名對應(yīng)的目錄地址 Direc
這里是指同一IP 綁定N 個域名,有二種方式實現(xiàn)
方法1、僅修改httpd.conf
假設(shè)二個域名bbs.xxx.com 與blog.xxx.com
打開httpd.conf
將文件拖到最下面,加上
1.
2. ServerName bbs.xxx.com #域名
3. DocumentRoot "F:/website/bbs" #該域名對應(yīng)的目錄地址
4.
5. Options FollowSymLinks IncludesNOEXEC Indexes
6. DirectoryIndex index.php
7. AllowOverride None
8. Order Deny,Allow
9. Allow from all
10.
11.
12.
13.
14. ServerName blog.xxx.com
15. DocumentRoot "D:/PHPSite/wordpress"
16.
17. Options FollowSymLinks IncludesNOEXEC Indexes
18. DirectoryIndex index.php
19. AllowOverride None
20. Order Deny,Allow
21. Allow from all
22.
23.
重啟apache ,就OK 啦。當(dāng)然你要修改你的hosts 文件。
方法2、修改PhpServerApache2.2confextrahttpd-vhosts.conf
直接將上面一段copy 到httpd-vhosts.conf 的最后即可。
實際上看名字就知道httpd-vhosts.conf 是一個虛擬站點配置集中地,方便管理。
也就是如下:
#
# Virtual Hosts
,#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. #
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host # configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any
#
ServerName bbs.xxx.com #域名
DocumentRoot "F:/website/bbs" #該域名對應(yīng)的目錄地址
DirectoryIndex index.php
AllowOverride None
Order Deny,Allow
Allow from all
ServerName blog.xxx.com
DocumentRoot "D:/PHPSite/wordpress"
Options FollowSymLinks IncludesNOEXEC Indexes
,DirectoryIndex index.php
AllowOverride None
Order Deny,Allow
Allow from all
重啟apache 。
如果不行的話,看你的httpd.conf 是否啟用了vhost
打開httpd.conf ,找到
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
看是否啟用,即去掉Include conf/extra/httpd-vhosts.conf前的# 重啟apache 。