wamp環境安裝thinkphp5.0-wamp環境配置vhosts

環境
windows7 , wampserver集成環境 , thinkphp5.0文件
wamp目錄:D:/wamp/www
thinkphp目錄:F:/tp5
thinkphp入口文件:F:/tp5/public/index.phpphp

第一步:修改http.conf文件,將http-vhosts.conf配置文件包含進來
點擊wamp-apache-http.conf,用記事本打開,定位到此處。web

# Virtual hosts  
#Include conf/extra/httpd-vhosts.conf  
改成  
# Virtual hosts  
Include conf/extra/httpd-vhosts.conf

注意:不要去掉第一個#號,不然wamp沒法正常運行thinkphp

第二步:配置http-vhosts.conf
點擊wamp-apache-http-vhosts.conf,用記事本打開,全選粘貼如下內容。apache

# 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 webmaster@dummy-host.example.com  
        DocumentRoot "D:\wamp\www"  
        ServerName localhost  
        ServerAlias www.dummy-host.example.com  
        ErrorLog "logs/localhost-error.log"  
        CustomLog "logs/localhost-access.log" common  
    </VirtualHost>  
      
    <VirtualHost *:80>  
        ServerAdmin webmaster@dummy-host2.example.com  
        DocumentRoot "F:\tp5\public"  
        ServerName tp5.com
        ErrorLog "logs/tp5.com-error.log"  
        CustomLog "logs/tp5.com-access.log" common  
        <Directory />  
            Require all granted  
        </Directory>  
    </VirtualHost>

在第一個例子中只改動了servername和documentRoot,這個配置保證了咱們在開啓vhost後仍然能夠訪問www目錄。
在第二個例子中,除了修改serverName和documentRoot之外,還添加了Directory那句話,若是不添加這句話,當咱們訪問tp5.com的時候會報403權限的錯誤。windows

注意:瀏覽器

DocumentRoot "F:\tp5\public"  #填寫入口文件所在的文件夾
        ServerName tp5.com            #用tp5.com來訪問這個網站入口文件

第三步:修改C:\Windows\System32\drivers\etc\hosts文件
在最後一行加入thinkphp5

127.0.0.1 tp5.com

最後重啓wamp,在瀏覽器輸入tp5.com
若是看到這樣的頁面就成功了:)
圖片描述網站

一鍵操做
點擊wamp主頁的Tool欄目下的Add a Virtual Host,能夠幫助你一鍵添加vhost
可是訪問wamp主頁時頁面出現以下警告(暫不清楚緣由):ui

The number of <Directory or </Directory> does not match the number of ServerName in d:/wamp/bin/apache/apache2.4.23/conf/extra/httpd-vhosts.conf file
The number of <VirtualHost does not match the number of ServerName in d:/wamp/bin/apache/apache2.4.23/conf/extra/httpd-vhosts.conf file

參考:wamp環境下配置vhostspa

相關文章
相關標籤/搜索