码迷,mamicode.com
首页 > Web开发 > 详细

apache配置端口

时间:2015-08-04 15:04:08      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

Apache2.2\conf\httpd.conf与Apache2.2\conf\extra\httpd-vhosts.conf两个文件的操作

 

httpd.conf下apache默认是80端口,找到 Listen 80就可以修改,想要增加新的端口直接添加一个Listen 8080之类的就OK了,如

Listen 8080

Listen 8081,如果没有为不同的端口指定目录,它们都访问DocumentRoot

修改目录:

apache默认访问的是安装目录下的htdocs,默认打开就出来It Works!,它由DocumentRoot定义如:

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

如果你想将换个目录可以直接DocumentRoot "x:/workspace/project/www"

 

授权:修改目录后,还要给目录设置访问的权限,如果不给权限是不能访问的。如:

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

 

配置多目录:

当前项目有两个分支,一个在trunck/www下面,另一个在branch/www下面,于是想localhost:8080访问trunck/www,localhost:8081访问branch/www

 

首先要开启虚拟主机:找到httpd.conf中#Include conf/extra/httpd-vhosts.conf,去掉前面的#号

接着配置不同url对应的目录,找到extra/httpd-vhosts.conf

修改默认端口80与8080,并添加一个8081的端口

NameVirtualHost *:8080

 

NameVirtualHost *:8081

设置目录:

<VirtualHost *:8080>

    ServerAdmin webmaster@dummy-host.smiky

    DocumentRoot "D:/work/trunk/www"

    ServerName dummy-host.smiky

    ServerAlias www.dummy-host.smiky

    ErrorLog "logs/dummy-host.smiky.log"

    CustomLog "logs/dummy-host.smiky-access.log" common

</VirtualHost>

<VirtualHost *:8081>

    ServerAdmin webmaster@dummy-host.smiky

    DocumentRoot "D:/work/branch/www"

    ServerName dummy-host.smiky

    ServerAlias www.dummy-host.smiky

    ErrorLog "logs/dummy-host.smiky.log"

    CustomLog "logs/dummy-host.smiky-access.log" common

</VirtualHost>

配好后,再回到httpd.conf中为这两个目录添加权限

<Directory "D:/work/trunk/www">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

<Directory "D:/work/branch/www">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

apache配置端口

标签:

原文地址:http://www.cnblogs.com/yueryuermaomao/p/4701812.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!