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和域名的映射關係
相關文章
相關標籤/搜索