我想在IIS中部署Nuxt,但我正在使用IIS节点,但我无法使它正常工作...Folder
我可以在服务器上使用npm run start来完成它,但是我还有其他项目,例如admin y api(.net),它正在使用端口80,因此当我使用端口80时,它在IIS中很忙,与此同时它也可以使用结构体Folder 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>
在我拥有带有express的server.js之前忽略nuxt.config.js,但是它不起作用,因为我正在使用ES6,并且当它尝试运行nuxt.config时,在语法上出现了错误
1)确保已安装节点。
https://nodejs.org/en/download/
2)使用以下命令创建nutx应用程序:
npm init nuxt-app testnu
3)进入app文件夹并运行以下命令来构建站点:
npm run generate
此命令将在您的应用程序文件夹中生成dist文件夹。
4)在IIS中创建一个站点,并将dist文件夹路径指向站点路径并分配站点绑定信息。
5)不要忘记为站点文件夹分配iis_iusrs和iusr权限。(我的情况是站点文件夹为testnu)
6)进行更改并浏览站点后刷新并重新启动站点。