图片:
前几天有个网上一起看php100视频学习php的朋友问我怎么在wamp上不同目录挂多个网站,我在网上搜了下资料,自己琢磨了一下午,现在把自己的方法公布出来,欢迎大家指正。也希望大家有更好的办法也公布出来。
以下方法是在wamp已经能正常运行后才能做的,如果说你wamp都没能成功运行,以下方法是不能用的。
第一要做的是安装第二个apache服务
一、找到Apache2的htppd.conf文件.例如:我的wamp是安装在G盘的,我的就是G:\wamp\Apache2\conf目录下.大家自己的是安装在哪里的自己换路径,后面不再重复说这话了。
二、复制htppd.conf,粘贴后在conf目录下后更名www2.conf (这里www2是自定义的,你想变成什么名字都可以。不过没试过中文的可行不。)
三、用用编辑器打开(用什么编辑器无所谓了,记事本就可以)打开www2.conf 找到如下代码
Listen 80
ServerName localhost:80
DocumentRoot "G:/wamp/www"
<Directory "G:/wamp/www">
更改为
Listen 8080/8080是新的apache服务监听的端口,可以自己改成自己想监听的。例如:8888
ServerName localhost:8080
DocumentRoot "G:/wamp/www2"/www2是我们第二个网站的目录
<Directory "G:/wamp/www2">
然后在G:/wamp下建一新文件夹为 www2
四、接下来就是安装服务了,
方法一:打开G:\wamp\Apache2\bin目录,新建一个txt文档,文档内容如下:(红色字部分)
httpd.exe -k install -n "www2" -f "G:\wamp\Apache2\conf\web2.conf"
保存后,更改文件名字以及后缀为www2.bat,双击运行就可以了
方法二:windows下面点击“开始”-“运行”输入“cmd”然后回车,打开命令提示符
把命令提示符切换到G:\wamp\Apache2\bin
输入
httpd.exe -k install -n "www2" -f "G:\wamp\Apache2\conf\web2.conf"
后按回车就可以了。
然后我们在www2下放一个html文件来做测试,在ie输入
http://localhost:8080 OK。服务正常
第二要做的就是服务安装好之后 就是怎么用wamp控制台来控制新安装的服务了
一、打开wamp目录,找到wampmanager.ini用编辑器打开(用什么编辑器无所谓了,记事本就可以)
二、主要更改的有(更改过的是红色的)
1
[Services]
Name: wampapache
Name: wampmysqld
[Services]
Name: wampapache
Name: wampmysqld
Name: www2
2
[StartupAction]
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
[StartupAction]
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: www2; ServiceAction: startresume; Flags: ignoreerrors
3
[Menu.Left]
Type: separator; Caption: "WAMP5"
Type: item; Caption: "Localhost"; Action: run; FileName: "C:\WINDOWS\explorer.exe"; Parameters: "
http://localhost/"; Glyph: 5
Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "C:\WINDOWS\explorer.exe"; Parameters: "
http://localhost/phpmyadmin/"; Glyph: 5
Type: item; Caption: "www 目录(&)"; Action: shellexecute; FileName: "G:/wamp/www"; Glyph: 5
[Menu.Left]
Type: separator; Caption: "WAMP5"
Type: item; Caption: "Localhost"; Action: run; FileName: "C:\WINDOWS\explorer.exe"; Parameters: "
http://localhost/"; Glyph: 5
Type: item; Caption: "Localhost:8080"; Action: run; FileName: "C:\WINDOWS\explorer.exe"; Parameters: "
http://localhost:8080/"; Glyph: 5
Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "C:\WINDOWS\explorer.exe"; Parameters: "
http://localhost/phpmyadmin/"; Glyph: 5
Type: item; Caption: "www 目录(&)"; Action: shellexecute; FileName: "G:/wamp/www"; Glyph: 5
Type: item; Caption: "www2目录(&)"; Action: shellexecute; FileName: "G:/wamp/www2"; Glyph: 5
4
[StartAll]
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
[StartAll]
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: www2; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
5
[StopAll]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
[StopAll]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: www2; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
6
[RestartAll]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
[RestartAll]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: www2; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: www2; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
7
[myexit]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
Action: exit
[myexit]
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: www2; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
Action: exit
三、更改完成之后保存,并重启wamp就ok了。下面图是我在机子上装有3个服务之后的样子了。
本贴来源http://bbs.php100.com/read-htm-tid-7362.html