angular / universal-starter

Angular Universal starter kit by @AngularClass
2.02k stars 688 forks source link

How to Deploy angular universal in Plesk shared windows server #656

Open amir-Yegane opened 5 years ago

amir-Yegane commented 5 years ago

I am working on Angular 6 implementing Angular Universal Rendering while in production Angular Universal working on the local machine that I can easily deploy and run. But when I started deploying the Angular Universal in Plesk shared windows server it's not working unexpectedly. I followed several links but there was less information. Please, I need some help in how to deploy Angular Universal Rendering in Plesk shared windows server. Appreciate your help Guys! Thank You! this is my steps: 1- I deployed like this:

npm run build:ssr && npm run serve:ssr

2- I upload dist folder on my host with this structure: 1 3- then I Enabled Node.js on my server and run NPM install. after installing the following warning is returned.

NPM install npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

I am not sure are they important or no?

4- I copied the following codes in web.config

<handlers> <add name="iisnode" path="dist/Kabook-Web/server.js" verb="*" modules="iisnode" /> </handlers>

<rewrite> <rules> <rule name="myapp"> <match url="/*" /> <action type="Rewrite" url="dist/Kabook-Web/server.js" /> </rule> <!-- Don't interfere with requests for node-inspector debugging --> <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^dist/Kabook-Web/server.js\/debug[\/]?" /> </rule>

</rules>

</rewrite>

<directoryBrowse enabled="true" />

<iisnode devErrorsEnabled="true" debuggingEnabled="true" loggingEnabled="true" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />

5- then I copied the following code in server.js as has been explained in this link Plesk Windows deploy node.js app.use(express.static('dist/Kabook-Web'));

then I run my website and face with this error in explorer.

iisnode encountered an error when processing the request.

   HRESULT: 0x2
   HTTP status: 500
   HTTP subStatus: 1002
   HTTP reason: Internal Server Error
   You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

   In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

   The node.exe process has not written any information to stderr or iisnode was unable
   to capture this information. Frequent reason is that the iisnode module is unable 
   to create a log file to capture stdout and stderr output from node.exe. 
   Please check that the identity of the IIS application pool running the node.js 
   application has read and write access permissions to the directory on the server 
   where the node.js application is located. Alternatively you can disable logging 
   by setting system.webServer/iisnode/@loggingEnabled element of web.config to 'false'.

I don't know how to solve it. please, someone help me...

mcrilly commented 5 years ago

Hi, I assume you got this working, did you ensure that the additional write/modify permissions were enabled as shown here in the red box: image

I'd like to know if you eventually got everything running as you'd like as I'm facing a similar situation trying to get my angular 8 app hosted on a plesk shared environment to serve static prerendered pages.