【www.30064.com】Apache服务器中配备虚构机的主意,设置本地设想域名windows

博客园博客园设想机开辟配置步骤及介绍。
1、由于前面设想机中供给用到Rewrite所以先编写制定Apache的conf目录下的httpd.conf文件。(可依照实际需求操作)
添加mod_rewrite.so模块援助。去掉下列行中前边的#号。
LoadModule rewrite_module modules/mod_rewrite.so
2、配置apache援救设想机。这一步很关键。
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
找到 上面相关文件,去掉#Include conf/extra/httpd-vhosts.conf前的#。
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
保留退出。
3、编辑conf目录下extra文件夹下的httpd-vhosts.conf。
去掉实例配置,加多新有配备。以搜狐博客园为例,配置文件如下:
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most
configurations
# use only name-based virtual hosts so the server doesn’t need to worry
about
# IP addresses. This is indicated by the asterisks in the directives
below.
#
# Please see the documentation at
# <URL:;
# for further details before you try to setup virtual hosts.
#
# You may use the command line option ‘-S’ to verify your virtual
host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
#领队邮箱
ServerAdminjiangfeng3@staff.sina.com.cn
#项目根目录
DocumentRoot “D:/htdocs/frame_export”
#域名
ServerName test.t.sina.com.cn
#别名
ServerAlias test.t.sina.com.cn
#错误日志路线
ErrorLog “logs/test.t.sins.com.cn-error.log”
CustomLog “logs/test.t.sins.com.cn-access.log” common
RewriteEngine on
#重写法规,可按照实际要求增多
RewriteRule ^/$ /apps/index.php [L]
</VirtualHost>
4、编辑本地host文件,以windows为例
进入C:/Windows/System32/drivers/etc
记事本展开hosts文件
最终增添
127.0.0.1 localhost
127.0.0.1 test.t.sina.com.cn
例子:
# Copyright 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host
name.
# The IP address and the host name should be separated by at least
one
# space.
#
# Additionally, comments (such as these) may be inserted on
individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
#::1 localhost
127.0.0.1 test.t.sina.com.cn
保留退出
5、重启apache,浏览器输入

什么样促成apache设想主机配置。

C:\WINDOWS\system32\drivers\etc\hosts

转发请注脚原来的小说地址:

1、基于ip地址的设想主机
Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot /home/httpd/html1
ServerName www.ok1.com
ErrorLog /usr/local/apache/logs/error1_log
CustomLog /usr/local/apache/logs/access1_log combined
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /home/httpd/html2
ServerName www.ok2.com
ErrorLog /usr/local/apache/logs/error2_log
CustomLog /usr/local/apache/logs/access2_log combined
</VirtualHost>
2、基于IP 和多端口的设想主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080

在那几个文件中 最上面增多。

<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example1.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example2.org
</VirtualHost>
3、单个IP 地址的服务器上根据域名的虚拟主机配置
# Ensure that Apache listens on port 80
Listen 80
#【www.30064.com】Apache服务器中配备虚构机的主意,设置本地设想域名windows。 Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>
若果你感觉方面包车型地铁小说还远远不够详细能够看下上边包车型客车稿子:

[html] view
plain copy

实验对象:在apache落成基于域名的设想主机
尝试用的XAMPP版本为1.7.7,内含apache版本为2.2.21

 

尝试前计划:
1.

  1. 127.0.0.1   localhost.com  
  2. 127.0.0.1   cho.com  
  3. 127.0.0.1   devwo.com  
  4. 127.0.0.1   phpmyadmin.com  

为了测试分化的域名,在Windows/System32/drivers/etc/下觅得hosts文件,在中间增多实验用的域名若干,如

127.0.0.1 test1.net
127.0.0.1 test2.net
像这种类型,则在浏览器中输入该俩域名时,Windows将其深入分析为127.0.0.1地面地址。即,在浏览器中探问localhost,
test1.net, test2.net均可访谈XAMPP的款待页。
2.
在apache目录下成立目录,以放置您分化的网址。为爱慕XAMPP原有的htdocs中的接待页内容,实验其它营造了与htdocs平级的htdocs1目录,在其下组建了test1.net,
test2.net八个子目录用以放置实验用的网址。如下 –
apache/htdocs1/test1.net – 放置test1.net网址内容
apache/htdocs1/test2.net – 放置test2.net网址内容
在那五个目录中各新建hello world一网页 index.html,内容 –
<HTML>
<HEAD></HEAD>
<BODY>
<H1>hello~,
这是[相应的网址名,用以差距].net</H1></BODY>
</HTML>
试验步骤:

  1. 找到apache/conf/httpd.conf, 将内部的
    ServerAdmin
    ServerName
    DocumentRoot
    注释掉。

  2. 在httpd.conf中,找到行
    Include “conf/extra/httpd-vhosts.conf”
    如被讲明则解注。该公文记载了虚构主机的参数。[先前设想主机参数是一贯填写在httpd.conf中的,为了越来越好地组织文件,将其分手出去,类似于一些编制程序语言同样。由此httpd.conf中include它,即一对一于把它的剧情填在了httpd.conf中。]

  3. 其一httpd-vhosts.conf文件格式基本如下 –
    #blah-blah
    NameVirtualHost *:80
    #blah-blah
    #blah-blah
    <VirtualHost *:80>
    ServerAdmin XXXXXXXX
    DocumentRoot “XXXXXXXX”
    ServerName XXXXXXX
    ServerAlias XXXXXX
    ErrorLog “logs/XXXXXX-error.log”
    CustomLog “logs/XXXXXXX-error.log” combined
    </VirtualHost>
    亟待修改的,正是<VirtualHost>中的参数了。那些能够参见apache官方文书档案。依照实验域名,能够追加五个<VirtualHost>:
    <VirtualHost *:80>
    ServerAdmin adm@test1.net
    DocumentRoot “C:/xampp/htdocs1/test1.net”
    ServerName test1.net
    ServerAlias www.test1.net
    ErrorLog “logs/test1-error.log”
    CustomLog “logs/test1-access.log” combined

<Directory “C:/xampp/htdocs1/test1.net”>
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin adm@test2.net
DocumentRoot “C:/xampp/htdocs1/test2.net”
ServerName test2.net
ServerAlias www.test2.net
ErrorLog “logs/test1-error.log”
CustomLog “logs/test1-access.log” combined

<Directory “C:/xampp/htdocs1/test2.net”>
order allow,deny
allow from all
</Directory>
</VirtualHost>
留神,假诺不在各VirtualHost中定义Directory的可访谈性,你将遭遇的是Access
Forbidden!就连本来的localhost也是。

  1. 是因为事先注释掉了httpd.conf中的ServerName,
    DocumentRoot等,为了仍旧能以localhost访问原XAMPP应接页,就在扩张一个VirtualHost,如下
  • <VirtualHost *:80>
    ServerAdmin adm@localhost
    DocumentRoot “C:/xampp/htdocs”
    ServerName localhost

ErrorLog “logs/localhost-error.log”
CustomLog “logs/localhost-access.log” combined

<Directory “C:/xampp/htdocs”>
order allow,deny
allow from all
</Directory>
</VirtualHost>
为了制止失误,把它放置在第2个Virtualhost地方。

现今,apache基于域名的虚构主机配置达成。能够透过
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most
configurations
# use only name-based virtual hosts so the server doesn’t need to worry
about
# IP addresses. This is indicated by the asterisks in the directives
below.
#
# Please see the documentation at
# <URL:;
# for further details before you try to setup virtual hosts.
#
# You may use the command line option ‘-S’ to verify your virtual
host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin kongdaoxian@gmail.com
DocumentRoot “E:/jbxue/apache2/htdocs”
ServerName localhost
ServerAlias www.jbxue.com
ErrorLog “logs/localhost-error.log”
CustomLog “logs/localhost-access.log” combined

<Directory “E:/jbxue/apache2/htdocs”>
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kongdaoxian@gmail.com
DocumentRoot “E:/jbxue/apache2/htdocs/project1”
ServerName project1.com
ServerAlias www.project1.com
ErrorLog “logs/project1-error.log”
CustomLog “logs/project1-access.log” combined

<Directory “E:/jbxue/apache2/htdocs/project1”>
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kongdaoxian@gmail.com
DocumentRoot “E:/jbxue/apache2/htdocs/jbxue/public”
ServerName jbxue.com
ServerAlias www.jbxue.com
DirectoryIndex index.php
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kongdaoxian@gmail.com
DocumentRoot “E:/jbxue/apache2/htdocs/jbxue”
ServerName jbxue.com
ServerAlias www.jbxue.com
# DirectoryIndex index.php
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kongdaoxian@gmail.com
DocumentRoot “E:/jbxue/apache2/htdocs/test”
ServerName test.com
ServerAlias www.test.com
ErrorLog “logs/jbxue-error.log”
CustomLog “logs/jbxue-access.log” combined

<Directory “E:/jbxue/apache2/htdocs/test”>
order allow,deny
allow from all
</Directory>
</VirtualHost>

 

新闻来自:

D:\wamp\bin\apache\Apache2.2.17\conf\extra\httpd-vhosts.conf

添加与hosts 相应的 映射

[html] view
plain www.30064.com ,copy

 

  1. #  
  2. # Virtual Hosts  
  3. #  
  4. # If you want to maintain multiple domains/hostnames on your  
  5. # machine you can setup VirtualHost containers for them. Mostconfigurations  
  6. # use only name-based virtual hosts so the server doesn’t need toworry about  
  7. # IP addresses. This is indicated by the asterisks in thedirectives below.  
  8. #  
  9. # Please see the documentation at  
  10. #<URL:;  
  11. # for further details before you try to setup virtual hosts.  
  12. #  
  13. # You may use the command line option ‘-S’ to verify your virtualhost  
  14. # configuration.  
  15.   
  16. #  
  17. # Use name-based virtual hosting.  
  18. #  
  19. NameVirtualHost *:80  
  20.   
  21. #  
  22. # VirtualHost example:  
  23. # Almost any Apache directive may go into a VirtualHostcontainer.  
  24. # The first VirtualHost section is used for all requests that donot  
  25. # match a ServerName or ServerAlias in any<VirtualHost> block.  
  26. #  
  27. <VirtualHost *:80>  
  28.     ServerAdminwebmaster@dummy-host.hleclerc-PC.ingenidev  
  29.     DocumentRoot”C:/Dev/Projets/WampServer2-64b/install_files_wampserver2/bin/apache/Apache2.2.17/docs/dummy-host.hleclerc-PC.ingenidev”  
  30.     ServerNamedummy-host.hleclerc-PC.ingenidev  
  31.     ServerAliaswww.dummy-host.hleclerc-PC.ingenidev  
  32.     ErrorLog”logs/dummy-host.hleclerc-PC.ingenidev-error.log”  
  33.     CustomLog”logs/dummy-host.hleclerc-PC.ingenidev-access.log” common  
  34. </VirtualHost>  
  35.   
  36. <VirtualHost *:80>  
  37.     ServerAdminwebmaster@dummy-host2.hleclerc-PC.ingenidev  
  38.     DocumentRoot”C:/Dev/Projets/WampServer2-64b/install_files_wampserver2/bin/apache/Apache2.2.17/docs/dummy-host2.hleclerc-PC.ingenidev”  
  39.     ServerNamedummy-host2.hleclerc-PC.ingenidev  
  40.     ErrorLog”logs/dummy-host2.hleclerc-PC.ingenidev-error.log”  
  41.     CustomLog”logs/dummy-host2.hleclerc-PC.ingenidev-access.log” common  
  42. </VirtualHost>  
  43.   
  44. /*—————————–*/  
  45.  <VirtualHost *:80>  
  46.   Options None  
  47.   ServerAdmin cho.com  
  48.   DocumentRoot E:\PHP\PHPProject\inpiao  
  49.   ServerName cho.com  
  50.   ErrorLog logs/phpmyadmin.com-error_log  
  51.   CustomLog logs/phpmyadmin.com-access_log common  
  52.   php_admin_value open_basedir “E:\PHP\PHPProject\inpiao”  
  53. </VirtualHost>  
  54.   
  55. <VirtualHost *:80>  
  56.   Options None  
  57.   ServerAdmin devwo.com  
  58.   DocumentRoot E:\PHP\PHPProject\devwo  
  59.   ServerName devwo.com  
  60.   ErrorLog logs/phpmyadmin.com-error_log  
  61.   CustomLog logs/phpmyadmin.com-access_log common  
  62.   php_admin_value open_basedir “E:\PHP\PHPProject\devwo”  
  63. </VirtualHost>  
  64.   
  65. <VirtualHost *:80>  
  66.   Options None  
  67.   ServerAdmin localhost.com  
  68.   DocumentRoot E:\PHP\PHPProject  
  69.   ServerName localhost.com  
  70.   ErrorLog logs/phpmyadmin.com-error_log  
  71.   CustomLog logs/phpmyadmin.com-access_log common  
  72.   php_admin_value open_basedir “E:\PHP\PHPProject”  
  73. </VirtualHost>  
  74.   
  75. <VirtualHost *:80>  
  76.   Options None  
  77.   ServerAdmin phpmyadmin.com  
  78.   DocumentRoot D:\wamp\apps\phpmyadmin3.3.9  
  79.   ServerName phpmyadmin.com  
  80.   ErrorLog logs/phpmyadmin.com-error_log  
  81.   CustomLog logs/phpmyadmin.com-access_log common  
  82.   php_admin_value open_basedir “D:\wamp\apps\phpmyadmin3.3.9”  
  83. </VirtualHost>  

最后在 \conf\httpd.conf 中  开启
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图