IIS前后端部署详细教程以及遇到的问题
1.安装iis,打包获取
首先先参考了前后端分离-IIS部署Vue前端项目
的部分内容
2.HTTP错误500.19 -Internal Server Error
在安装好IIS成功以后,添加网站,网站启动报如下错误
经过研究官方文档
HRESULT 代码 0x8007000d
错误消息:
应用程序“应用程序名称”中的服务器错误
HTTP 错误 500.19 - 内部服务器错误
HRESULT:0x8007000d
对 HRESULT 的说明
由于此页相关的配置数据无效,则无法访问所请求的页。
原因
发生此问题的原因是 ApplicationHost.config 或 Web.config 文件包含格式不正确或无法识别的 XML 元素。 IIS 无法识别未安装模块的 XML 元素。 例如,IIS URL 重写模块。
解决方案
请使用以下方法之一:
从 ApplicationHost.config 或 Web.config 文件中删除格式错误的 XML 元素。
检查无法识别的 XML 元素,然后安装相关的 IIS 模块。
1.首先没有显示配置错误,是因为没有web.config文件。
2.添加web.config文件后,如果再报错根据官方文档解决方案进行处理。
发现是config文件有问题。重新拷贝了新的config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="CHRoutes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
<outboundRules>
<rule name="Remove ETag">
<match serverVariable="RESPONSE_ETag" pattern=".+" />
<action type="Rewrite" value="" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
注意rewrite代码段可能无法识别,这边要安装模块urlrewrite连接:
3.HTTP 错误 403.14 - Forbidden
然后重新启动报如下错误
在查看确定有配置所需的默认文档以后
尝试发布mvc报错:403.14-Forbidden Web 服务器被配置为不列出此目录的内容
增加如下代码
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
directoryBrowse 意思是允许启用目录,就可以在目录里面自动找到了
顺利解决!