Osw*_*man 5 iis iisnode vue.js nuxt.js
我想在 IIS 中部署 Nuxt,我正在使用 IIS Node,但我无法让它工作......

我可以在我的服务器中使用 npm run start 来完成它,但我还有其他项目,例如 admin y api (.net) 并且它使用端口 80,所以当我使用端口 80 时它很忙,而在 IIS 中它使用此结构

这是我在 web.config 中的代码
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="nuxt.config.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^nuxt.config.js\/debug[\/]?" />
</rule>
<!-- <rule name="Redirect to https" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule> -->
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="nuxt.config.js"/>
</rule>
</rules>
</rewrite>
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled
See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在我使用express的server.js之前忽略nuxt.config.js,但它不起作用,因为我使用的是ES6,当它尝试运行nuxt.config时出现语法错误
1)确保安装节点。
https://nodejs.org/en/download/
2)使用以下命令创建 nutx 应用程序:
npm init nuxt-app testnu
Run Code Online (Sandbox Code Playgroud)
3)进入app文件夹并运行以下命令来构建站点:
npm run generate
Run Code Online (Sandbox Code Playgroud)
此命令将在您的应用程序文件夹中生成 dist 文件夹。
4)在IIS中创建站点并将dist文件夹路径作为站点路径并分配站点绑定信息。
5)不要忘记为站点文件夹分配iis_iusrs和iusr权限。(我的情况站点文件夹是testnu)
6)更改后刷新并重新启动站点并浏览站点。
| 归档时间: |
|
| 查看次数: |
10241 次 |
| 最近记录: |