1 配置虚拟主机

配置虚拟主机

首先将安装的thinkphp放在apache根目录下的hotdocs目录内

Apache安装目录\Apache\conf 文件夹中找到httpd.conf文件,打开后,搜索以下三个内容:

LoadModule rewrite_module modules/mod_rewrite.soLoadModule vhost_alias_module modules/mod_vhost_alias.soInclude conf/extra/httpd-vhosts.conf

将前面的#号去掉

搜索


DirectoryIndex index.html index.php

中间项修改为

DirectoryIndex index.html index.php

以上操作是定义默认主页。

然后Apache安装目录\Apache\conf\extra目录找到httpd-vhost.conf文件,打开后,添加以下内容:


    ServerAdmin www.tp5.com
    DocumentRoot                 
    "${SRVROOT}/htdocs/tp5/public" 
       
    Options Indexes FollowSymLinks   
    AllowOverride None
    Require all granted 
    
    ServerName www.tp5.com
    ErrorLog "logs/tp5-error.log"
    CustomLog "logs/tp5-access.log" common

然后打开hosts文件C:\Windows\System32\drivers\etc\hosts,添加以下内容:

127.0.0.1       www.tp5.com

然后重启apache,在地址栏输入www.tp5.com就可以访问thinkphp5的主页了

你可能感兴趣的:(1 配置虚拟主机)