解决Windows的服务器宝塔IIS上安装thinkphp6无法设置public运行目录

www.jswusn.com 服务器 2021-02-04 18:13:48 2025次浏览

今天在一个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}

测试各方面都没什么问题,搞定~ 

就是折腾了我几个小时,心累~

上一篇:没有了!

服务器

下一篇:百度云BCH简单的conf文件设置

苏南名片

  • 电话:152-1887-1916
  • 邮箱:message@jswusn.com
  • 地址:江苏省苏州市相城区

Copyright © 2018-2024 jswusn.com 版权所有

技术支持:苏州网站建设  苏ICP备18036849号