Apache配置多个网站
你可以全用本地私有ip地址创建多个站点 127.0.0.x,这个网段的所有ip都是指向本机的,并且可以区分,这是计算机的私有ip地址,供测试用的,配置方法如下
一、打开httpd.conf
1、从ServerAdmin admin@localhost
一直到:
<IfModule dir_module>
DirectoryIndex index.html index.php index.php3 index.htm
</IfModule>
2、在D盘创建文件夹d:/website做为所有站点的父文件夹,以后的子站点全部放到这个文件夹内。
3、将刚才找到的区域代码修改如下:
ServerAdmin admin@localhost
ServerName localhost:80
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "d:/website/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php index.php3 index.htm
</IfModule>
#上面这句话是让apache对website及子文件夹有完全访问的权限,以后的站点全部放在该目录下
二、子站点配置方法
1、在httpd.conf文件中,找到
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
修改为
# Virtual hosts
Include d:/website/httpd-vhosts.conf
2.在 wamp/bin/apache/apache2.2.17/conf/extra/找到httpd-vhosts.conf文件,
复制到:d:/website文件夹下
3.在d:/website/创建子站点文件夹, 假如:d:/website/wwwroot1/
4.修改 d:/website/httpd-vhosts.conf 文件的内容
<VirtualHost 127.0.0.2:80>
DocumentRoot "d:/website/wwwroot1/"
ServerName 127.0.0.2
</VirtualHost>
5.保存httpd.conf,保存httpd-vhosts.conf,然后重启apache 服务
6.测试 在wwwroot1,下创建文件:index.php 用记事本来写入这些代码:
<?php
phpinfo();
?>
保存,然后打开浏览器,在地址栏里输入:http://127.0.0.2 会出现相关信息
7.建第二个站点,在website目录创建文件夹:d:/website/wwwroot2/
打开文件:d:/website/httpd-vhosts.conf
在追加站点配置代码如下:
<VirtualHost 127.0.0.3:80>
DocumentRoot "d:/website/wwwroot2/"
ServerName 127.0.0.3
</VirtualHost>
根据第5,6步进行重启服务与测试
三、到hosts下将需要的ip修改为方便记忆输入的域名。
hosts路径:C:\Windows\System32\drivers\etc
127.0.0.2 localhost2
最新文章
- hdu-2444-二分图判定+最大分配
- 【CQgame】[下一百层] [Down]
- [CareerCup] 17.7 English Phrase Describe Integer 英文单词表示数字
- linux 安装redmine 遇到的问题
- iOS 时间处理(转)
- 如何分割一个utf8字符串(保证单个汉字的完整性)
- SQL查询中关于索引使用的笔记
- mongodb .net driver
- 局部化原理(Laplace渐进估计方法)
- UltraEdit 列模式
- 将FAT32格式转换成NTFS格式命令
- js垃圾回收机制
- UWP 使用Telerik Grid控件
- anylogic 使用
- append和appendTo的区别!
- 运输计划NOIP2015Day2T3
- 星图智控推嵌入式家用AI摄像头
- Javascript删除数组里的某个元素
- web@css样式进阶--图形字体、动画、显隐....
- Mysql错误:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction