Apache虚拟主机配置

虚拟主机的配置     1)开启httpd-vhosts.conf     include conf/extra/httpd-vhosts.conf     2)在httpd-vhosts.conf中配置     <VirtualHost localhost:80>         serverName shunping.com         DocumentRoot "d:/myblog"         # 配置欢迎页面         DirectoryIndex index.html index.htm index.php         <Directory "d:/myblog">             # 不容许以列表形式             options FollowSymLinks             # 不容许其余人修改页面             Allowoverride None             # 权限设置             order allow,deny             allow from all         </Dirctory>     </VirtualHost>     3)修改hosts文件     windows下在 c:/windows/system32/drivers/etc/hosts     添加 ip 和主机映射关系     ip           域名     127.0.0.1    shunping.com     这样输入shunping.com就能够访问咱们本地的网站了,而不是跳转到真正的搜狐页面     注意:     处于安全性考虑,都会将allowoverride 设置成none     none的时候,会忽略.htaccess文件     指令为all的时候,全部具备.htaccess做用域的指令都容许出如今.htaccess文件中     对于URL rewrite 来讲,至少须要把目录设置为     <Directory /myblog>         allowoverride FileInfo     </Directory>     allowoverride 可选指令     a.AuthConfig 容许使用全部的权限指令       包括 AuthDBMGroupFile AuthDBMUserFile AuthGroupFile AuthName AuthType AuthUserFile Require     b.FileInfo 容许使用文件控制类型的指令       包括 AddEncoding AddLanguage AddType DefaultType ErrorDocument LanguagePriority     c.Indexes 容许使用目录控制类型的指令       包括 AddDescription AddIcon AddIconByEncoding AddIconByType DefaultIcon            DirectoryIndex FancyIndexing HeaderName IndexIgnore IndexOptions ReadmeName     d.Limit 容许使用权限控制指令       包括 Allow Deny 和 order     e.Options 容许使用控制目录特征的指令       包括Options XBitHack       Options       1  All         准许如下除MultiViews之外全部功能       2  MultiViews  容许多重内容被浏览,          若是你的目录下有一个叫作foo.txt的文件,          那么你能够经过/foo来访问到它,这对于一个多语言内容的站点比较有用       3  Indexes     若该目录下无index文件,则准许显示该目录下的文件以供选择       4  IncludesNOEXEC  准许SSI,但不可以使用#exec和#include功能       5  Includes    准许SSI       6  FollowSymLinks          在该目录中,服务器将跟踪符号连接。          注意,即便服务器跟踪符号连接,它也不会改变用来匹配不一样区域的路径名,          若是在<Local>;标记内设置,该选项会被忽略       7  SymLinksIfOwnerMatch  在该目录中仅仅跟踪本站点内的连接       8  ExecCGI     在该目录下准许使用CGI 一个ip绑定多个域名 解决方案     1)经过端口来区分不一样的站点     ① 仍是按照绑定一个站点的方法作好准备       开发好网站 d:/myblog       配置httpd.conf文件,启用httpd-vhost.conf       配置httpd-vhost.conf       <VirtualHost 127.0.0.1:80>           DocumentRoot "d:/myblog"           DirectoryIndex index.html index.htm index.php           <Directory "d:/myblog">               Allowoverride none               Options FollowSymLinks               order allow,deny               allow from all           </Directory>       </VirtualHost>       在hosts文件中添加ip和域名的映射关系       127.0.0.1 www.shunping1.com       2)添加一个新的域名于该ip绑定       开发新的网站 d:/myblog2       配置httpd-vhost.conf       <VirtualHost 127.0.0.1:81>           DocumentRoot "d:/myblog2"           DirectoryIndex index.html index.htm index.php           <Directory "d:/myblog2">               Allowoverride none               Options FollowSymLinks               order allow,deny               allow from all           </Directory>       </VirtualHost>       在httpd.conf中让Apache监听81端口       Listen 81       在hosts文件中添加新的域名       127.0.0.1 www.shunping3.com       测试       http://www.shunping3.com:81/     2)解决方案二     经过serverName段来区分不一样的域名     开发新站点 d:/myblog2     配置httpd-vhost.conf     # 127.0.0.1 换成 *     <VirtualHost *:80>           DocumentRoot "d:/myblog3"           # 添加了这一行           serverName www.shunping3.com           DirectoryIndex index.html index.htm index.php           <Directory "d:/myblog3">               Allowoverride none               Options FollowSymLinks               order allow,deny               allow from all           </Directory>       </VirtualHost>       在hosts文件中添加ip和域名的映射关系
相关文章
相关标签/搜索