APMServ多站点架设

  • 发表于
  • PHP

经常使用APMServ,多站点架设基本是必须的,其他相关的软件(例如:appserv)同样适用。
第一步:首先打开Apache的配置文件 httpd.conf
找到如下字段:

#APMServ默认虚拟主机
NameVirtualHost *:80

ServerName *
DocumentRoot "D:/APMServ/www/htdocs"
<Directory "D:/APMServ/www/htdocs">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml
AllowOverride None
Order Deny,Allow
Allow from all
我们需要的字段如下:

ServerAdmin *
DocumentRoot "D:\APMServ\www\htdocs\"
ServerName *

ServerAdmin 这个直接忽略
DocumentRoot 表示目录所在地址
ServerName 这个表示域名

D:\APMServ\www\htdocs\ 这个目录是默认的web根目录. 我在里面建了3个文件夹 : web1 web2 web3
接下来就是把我们的文件夹名字写上去.
DocumentRoot "D:\APMServ\www\htdocs\web1"

ServerName localhost0.com 这个表示我在浏览器输入localhost0.com就会访问到 DocumentRoot 设定的目录

把我们写好的代码粘贴到 httpd.conf 文件的末尾.然后保存就可以了.
例如:

ServerAdmin *
DocumentRoot "D:\APMServ\www\htdocs\web1"
ServerName localhost0.com
ServerAdmin *
DocumentRoot "D:\APMServ\www\htdocs\web2"
ServerName localhost1.com
ServerAdmin *
DocumentRoot "D:\APMServ\www\htdocs\web3"
ServerName localhost2.com

第二步:修改hosts文件
其所在地址:C:\WINDOWS\system32\drivers\etc\hosts
用记事本程序打开,在下面加上:
127.0.0.1 localhost0.com
127.0.0.1 localhost1.com
127.0.0.1 localhost2.com
然后保存,重启apache服务器.
直接在浏览器输入 localhost0.com 就可以访问web1目录.
localhost1.com 就可以访问web2目录.
localhost2.com 就可以访问web3目录.

END……