2007/04 18
一般开发会使用localhost或者127.0.0.1来访问本机的apache。从apache2的某个版本开始,支持如127.*.*.*的地址如127.0.0.2来访问本机,当然,如果没有配置,得到的结果和localhost是一样的。
比如解析127.0.0.2的配置文件如下:

ServerAdmin webmaster@localhost

DocumentRoot E:/htdocs/phplibrary

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/


ErrorLog D:\Apache2.2\logs\phplibrary.cn_error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog D:\Apache2.2\logs\phplibrary.cn_access.log combined
ServerSignature On


把它加到你的apache配置中,重启apache就可以访问127.0.0.2.指向是跟127.0.0.1不同了。

但是这样的配置只能供你个人机访问,如果需要在局域网中其他人也访问到你的其他域,那就按照下面的来吧:
两种方式:
1.端口实现:
Listen 8080

DocumentRoot E:/htdocs/phplibrary
ErrorLog D:\Apache2.2\logs\phplibrary.cn_error.log
CustomLog D:\Apache2.2\logs\phplibrary.cn_access.log combined


其他人就可以通过你的ip,比如:192.168.0.106:8080来访问phplibrary站了。
同样,你还可以增加8081等等等等。。。

2.hosts文件实现
添加hosts文件行。windows中hosts文件位于:C:\WINDOWS\system32\drivers\etc
127.0.0.1       localhost
127.0.0.1	www.phplibrary.dev
127.0.0.1       www.phpfunction.dev
192.168.1.106	rollenc.www.phplibrary.dev
192.168.1.106	rollenc.www.phpfunction.dev
192.168.1.17	yourname.www.phplibrary.dev
192.168.1.17	yourname.www.phpfunction.dev

然后,添加apache配置:

ServerName www.phplibrary.dev
ServerAlias rollenc.2007.phplibrary.dev yourname.2007.phplibrary.dev  #这一行需要与hosts中的同步,单独修改hosts是无效的。
DocumentRoot E:/htdocs/phplibrary
ErrorLog D:\Apache2.2\logs\phplibrary.cn_error.log
CustomLog D:\Apache2.2\logs\phplibrary.cn_access.log combined


再加一站点:

ServerName www.phpfunction.dev
ServerAlias rollenc.2007.phpfunction.dev yourname.2007.phpfunction.dev  #这一行需要与hosts中的同步,单独修改hosts是无效的。
DocumentRoot E:/htdocs/phpfunction
ErrorLog D:\Apache2.2\logs\phpfunction.cn_error.log
CustomLog D:\Apache2.2\logs\phpfunction.cn_access.log combined


OK,把hosts文件分发给你局域网内的成员。他们就可以通过rollenc.www.phplibrary.dev来访问rollenc机器上的www.phplibrary.dev域了。
Defined tags for this entry:

Posted by rollenc

Last modified on 2007-04-18 11:45

0 Trackbacks

  1. No Trackbacks

0 Comments

  1. No comments

Add Comment


E-Mail addresses will not be displayed and will only be used for E-Mail notifications.