修改IIS下的MATOMO站点配置文件导致500错误解决
本文最后更新于 181 天前,其中的信息可能已经有所发展或是发生改变。

事情的起因

我租了一台windows服务器,然后想要将matomo安装在这台服务器上面,这台服务器采用了宝塔面板+IIS+mysql+php,我正常的在服务器上安装完了matomo,并且成功运行起来了,但是安装完后宝塔面板站点管理中显示安装了matomo的网站配置文件不正确,无法解析,是否修复?结果,点击修复以后,matomo就故障了,报错500如下图。

原因分析

matomo在安装的过程中修改了该站点的IIS配置文件从而让matomo正常运行,但是我将修改过的配置文件恢复为默认的导致matomo无法正常运行,修复其实也很简单,将配置文件改回来即可,但是,弄之前按没有备份(备份真的真的是个好习惯啊!)所以只好重装,我会在下段将配置文件给出来

配置文件

首先我们要找到IIS的站点配置文件,在宝塔面板中可以直接前往站点管理界面来查看,如下图

或者也可以在站点目录中查看,文件名为web.config

下面这一段是IIS的默认站点配置文件

<?xml version="1.0" ?>
<configuration>
	<location path="." allowOverride="false" inheritInChildApplications="false">
		<system.webServer>
			<rewrite>
				<rules configSource="web_config\rewrite.config"></rules>
			</rewrite>
			<defaultDocument configSource="web_config\default.config"></defaultDocument>
			<httpErrors configSource="web_config\httpErrors.config"></httpErrors>
			<handlers configSource="web_config\php.config"></handlers>
		</system.webServer>
	</location>
</configuration>

下面这一段是安装 matomo后的IIS站点配置文件,假如一不小心将IIS的配置文件还原成默认的,用下面的配置覆盖即可。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment="config" ></add>
          <add segment="core" ></add>
          <add segment="lang" ></add>
          <add segment="tmp" ></add>
        </hiddenSegments>
        <fileExtensions>
          <add fileExtension=".tpl" allowed="false" ></add>
          <add fileExtension=".twig" allowed="false" ></add>
          <add fileExtension=".php4" allowed="false" ></add>
          <add fileExtension=".php5" allowed="false" ></add>
          <add fileExtension=".inc" allowed="false" ></add>
          <add fileExtension=".in" allowed="false" ></add>
          <add fileExtension=".csv" allowed="false" ></add>
          <add fileExtension=".pdf" allowed="false" ></add>
          <add fileExtension=".log" allowed="false" ></add>
        </fileExtensions>
      </requestFiltering>
    </security>
    <directoryBrowse enabled="false" ></directoryBrowse>
    <defaultDocument>
      <files>
        <remove value="index.php" ></remove>
        <add value="index.php" ></add>
      </files>
    </defaultDocument>
    <staticContent>
      <remove fileExtension=".svg" ></remove>
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" ></mimeMap>
      <remove fileExtension=".woff" ></remove>
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" ></mimeMap>
    </staticContent>
  </system.webServer>
</configuration>

感谢阅读。

本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议,记得载明出处,(期待)。内容有问题?点此反馈
上一篇
下一篇