🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
Thinkphp5将虚拟地址指向本地public目录,开启重写方法 Apache设置本地虚拟Vhost方法: 1、找到hosts文件 ![](https://box.kancloud.cn/327db0330febadaf6040d9c2704796e3_601x187.png) 2、修改内容:增加几个127.0.0.1的域名 ![](https://box.kancloud.cn/339cbc1a9ff26a1fa43e3cc0fdb43e95_519x134.png) 3、设置Apache的Apache\conf\extra\httpd-vhosts.conf文件: ~~~ #<VirtualHost *:80> # ServerAdmin webmaster@dummy-host2.example.com # DocumentRoot "/Apache24/docs/dummy-host2.example.com" # ServerName dummy-host2.example.com # ErrorLog "logs/dummy-host2.example.com-error.log" # CustomLog "logs/dummy-host2.example.com-access.log" common #</VirtualHost> ~~~ 改成hosts文件里一样的名称,并将“DocumentRoot”指向需要的public目录 4、检查这两个文件:httpd-conf和vhosts-conf中包含了修改的内容。 ![](https://box.kancloud.cn/5a0788530f8f520dada802aa011627cc_276x104.png) httpd-conf: ~~~ DocumentRoot "D:\phpStudy\WWW" <Directory /> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> ~~~ vhosts-conf ~~~ <VirtualHost *:80> DocumentRoot "D:\phpStudy\WWW\eaoophp\public" ServerName www.eaoophp.com ServerAlias eaoophp.com <Directory "D:\phpStudy\WWW\eaoophp\public"> Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost> ~~~ 另外有时APACHE服务器出现No input file specified.原因在于使用的PHP是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误,此时修改你项目目录下的.htaccess文件: ~~~ <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule> ~~~ 这句: `RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]` 改成 ` RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]` 不知道是啥意思,反正改了就好了! 最后别忘了,要重新启动一下你的本地服务器(phpstudy什么的)