今天在一个windows的服务器iis上安装thinkphp6,按照正常理解应该把站点运行目录设置在public,但是安装完打开报错显示:
{pboot:pre}
Warning: require(D:webendorutoload.php): failed to open stream: Too many open files in D:webpublicindex.php on line 15 Fatal error: require(): Failed opening required 'D:webpublic/../vendor/autoload.php' (include_path='.;C:phppear') in D:webpublicindex.php on line 15
{/pboot:pre}
想去看看安装的环境有没有问题,把运行目录改回根目录,访问public发现可以正常生成,也不报错了。这就让我蒙了,之前一直用的linux服务器从来没有出现过这样的问题呀!
但是总不能让用户每次访问都手动加public吧。于是让URL重写帮我们加public吧。
折腾了半天把根目录下的web.config拼凑出来了
{pboot:pre}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
< system.webServer>
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^(.*)$" / >
<conditions logicalGrouping="MatchAll">
<add input="{APPL_PHYSICAL_PATH}public{PATH_INFO}" matchType="IsFile" negate="true" />
<add input="{APPL_PHYSICAL_PATH}public{PATH_INFO}" matchType="IsDirectory" negate="true" />
</conditions >
<action type="Rewrite" url="/public/index.php/{R:1}" />
</rule >
<rule name="public" stopProcessing="true" >
<match url="^(.*)$" ignoreCase="false" / >
<conditions logicalGrouping="MatchAll" >
<add input="{URL}" pattern="^/public/" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/public/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>{/pboot:pre}
测试各方面都没什么问题,搞定~
就是折腾了我几个小时,心累~









