转载相关:http://blog.csdn.net/tegwy/article/details/8811460
首页安装正常的WampServer,安装成功后能够正常运行。如下图:
下面第一步就是安装第二个apache服务
一、找到Apache2的htppd.conf文件.例如:我的wamp是安装在I盘的,我的就是I:\wamp\bin\apache\apache2.2.22\conf目录下。
二、复制httpd.conf,粘贴后在conf目录下后更名httpd2.conf(这里httpd2.conf是自定义的。)
三、用用编辑器打开httpd2.conf 找到如下几行代码 (不在一起的)
- Listen 80
- ServerName localhost:80
- DocumentRoot "i:/wamp/www/"
- <Directory "i:/wamp/www/">
- Listen 8080 //apache服务新监听的端口,可根据自己需要进行修改
- ServerName localhost:8080
- DocumentRoot "i:/wamp/www2/" //www2是我们第二个网站的目录
- <Directory "i:/wamp/www2/">
四、接下来就是安装服务了,
在桌面或其他地方新建个文本,贴入下面内容(注意目录)
- cd /d i:\wamp\bin\apache\apache2.2.22\bin
- httpd.exe -k install -n "www2" -f "i:\wamp\bin\apache\apache2.2.22\conf\httpd2.conf"
然后我们在www2下放一个html文件来做测试,在浏览器中输入 http://localhost:8080 OK。服务正常。如果此时无法访问,可能是因为服务还没启动,在windows服务中会有个我们刚刚新增的名为www2服务,如下图,启动他即可正常访问8080地址了
第二步要做的就是用wamp控制台来控制新安装的服务
一、打开wamp目录,找到wampmanager.ini用编辑器打开
二、相关的修改
其实主要就是全部停止服务、全部启动服务、地址、目录几个配置,只要看到 Service: wampapache 之类的配置然后在下面再加行 Service: www2配置就可以了
在这里有个需要注意的就是在配置之前先前 wampmanager.tpl 改名,不然如果配置文件里的配置与 wampmanager.tpl 不相符的话会自动给覆盖掉。
下面的修改供参考:
- [Services]
- Name: wampapache
- Name: wampmysqld
- Name: www2
- [StartupAction]
- ;WAMPSTARTUPACTIONSTART
- Action: run; FileName: "i:/wamp/bin/php/php5.3.13/php-win.exe";Parameters: "refresh.php";WorkingDir: "i:/wamp/scripts"; Flags: waituntilterminated
- Action: resetservices
- Action: readconfig;
- Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
- Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
- Action: service; Service: www2; ServiceAction: startresume; Flags: ignoreerrors
- ;WAMPSTARTUPACTIONEND
- [Menu.Left]
- ;WAMPMENULEFTSTART
- Type: separator; Caption: "Powered by Alter Way"
- Type: item; Caption: "Localhost"; Action: run; FileName: "C:\Program Files\Google\Chrome\Application\chrome.exe"; Parameters: "http://localhost/"; Glyph: 5
- Type: item; Caption: "Localhost 8080"; Action: run; FileName: "C:\Program Files\Google\Chrome\Application\chrome.exe"; Parameters: "http://localhost:8080/"; Glyph: 5
- Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "C:\Program Files\Google\Chrome\Application\chrome.exe"; Parameters: "http://localhost/phpmyadmin/"; Glyph: 5
- Type: item; Caption: "www directory"; Action: shellexecute; FileName: "i:/wamp/www"; Glyph: 2
- Type: item; Caption: "www2 directory"; Action: shellexecute; FileName: "i:/wamp/www2"; Glyph: 2
- [StartAll]
- ;WAMPSTARTALLSTART
- Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
- Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
- Action: service; Service: www2; ServiceAction: startresume; Flags: ignoreerrors
- [StopAll]
- ;WAMPSTOPALLSTART
- Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
- Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
- Action: service; Service: www2; ServiceAction: stop; Flags: ignoreerrors
- [RestartAll]
- ;WAMPRESTARTALLSTART
- Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
- Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
- Action: service; Service: www2; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
- Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
- Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
- Action: service; Service: www2; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
- [myexit]
- ;WAMPMYEXITSTART
- Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
- Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
- Action: service; Service: www2; ServiceAction: stop; Flags: ignoreerrors
- Action: exit
更改完成后保存并关闭wamp,并重启wamp就可以了。下面是我改后的效果:
设置www2只允许127.0.0.1和192.168.1.16访问
找到httpd2.conf并打开,找到<Directory
修改如下Order Allow,Deny
#Allow from all
Allow from 192.168.1.16
Allow from 127.0.0.1
保存退出,并重启wamp