配置apache5

  1. wamp控制下多目录挂网站

第一要做的是安装第二个apache服务

一、找到Apache2htppd.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


三、更改完成之后保存,并重启wampok了。下面图是我在机子上装有3个服务之后的样子了。

我不说具体的更改的用处是希望大家能自己琢磨下,想表达的观点:最好学习方法就是实践

 配置apache5_第1张图片

  1. Apache本地服务器下更改DocumentRoot和新建虚拟目录配置方法

Apache 安装后,默认的 DocumentRoot 是安装目录下的 htdocs 目录,编程时有很多不便,如需更改,打开安装目录 conf 子目录下的 httpd.conf 文件,修改 DocumentRoot 属性即可,如更改为:DocumentRoot "D:/www".

IIS 下,新建虚拟目录可通过可视化界面操作,在 Apache 中,新建虚拟目录通过修改 httpd.conf 文件实现。

httpd.conf alias_module 下增加一别名定义项,如:Alias   /ajax/   "D:/www/ajaxbook/"即可定义虚拟目录。

更改以上设置后,必须重启 Apache 才能使设置生效。同时,要对相应目录作权限定义,否则会出现无权访问的错误提示。

要对目录定义权限,可在 httpd.conf 文件中定义类似以下的代码:

Alias   /ajax/   "D:/www/ajaxbook/"
Alias   /ajax1/   "D:/www/ajaxstarrater/" //
注意这里的路径"/"目录下
<Directory   "D:/www/ajaxstarrater">
Options Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory> //
以上是目录权限设置

访问路径:http://localhost/ajax/
               http://localhost/ajax1/

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/uc
home
ServerName yourdomain.com
ServerAlias *.yourdomain.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/discuz/"
ServerName www.abc.com
<Directory "C:/wamp/www/discuz/">
Options -Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
</VirtualHost>

<VirtualHost 211.100.*.*:80>
    ServerAdmin [email protected]
    DocumentRoot /data/httpd-data/htdocs/manage
    ScriptAlias /cgi-bin/ "/data/httpd-data/cgi-bin/"
    ServerName mn.**.net
    ServerAlias mn.**.net
    ErrorLog /data/httpd-data/logs/mn_error_log
    CustomLog /data/httpd-data/logs/mn_access_log common
        <Directory />
                Options FollowSymLinks
                AllowOverride None
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost 211.100.*.*:80>
    DocumentRoot /data/web/www/www.***.com/
    ServerName www.***.cn
     ServerAlias ***.cn
     ErrorDocument 404 http://sz.***.com/miss.php
     ErrorLog /data/web/log/www.***.com/apache_error_log
<Directory /data/web/www/www.***.com/>
   Options -Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all              
</Directory>
</VirtualHost>

 

你可能感兴趣的:(apache,.net,service,phpMyAdmin,action,Parameters)