Skip to content
Lior Kesos edited this page Jun 16, 2015 · 13 revisions

Hosting MEAN in the cloud

Heroku

4 commands to deploy your mean app to heroku, Before you start make sure you have heroku toolbelt installed and an accessible mongo db instance - you can try mongohq which have an easy setup )

git init
git add .
git commit -m "initial version"
heroku apps:create
git push heroku master

AWS

Azure

Hosting MEAN on a Linux Server

Hosting MEAN on a Windows Server

  • Install NPM
  • Add your site in IIS and set Application Pool to No Managed Code / Integrated.
  • Install iisnode https://github.com/tjanczuk/iisnode - To test: after initial install copy their examples to your site folder. They should all work though my express demo did not. I ran their setupexample.bat and it destroyed my existing sites.
  • Make sure to give your site folder Read, Write access for the IUSER / Application Pool User. This is for the iisnode logging to write the log file. Otherwise you will get errors.
  • Delete the iisnode site from your folder. Copy your site from git into your site folder.
  • npm install / bower install
  • Add a web.config - below and it should work. Web.config
 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
<!--webSocket used for Windows Azure-->
		<!--<webSocket enabled="false" />-->
		<handlers>
			<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
		</handlers>
		<rewrite>
			<rules>
				<!-- Don't interfere with requests for logs -->
				<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
					<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
				</rule>

				<!-- Don't interfere with requests for node-inspector debugging -->
				<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
					<match url="^server.js\/debug[\/]?" />
				</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 application entry point -->
				<rule name="DynamicContent">
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
					</conditions>
					<action type="Rewrite" url="server.js" />
				</rule>
			</rules>
		</rewrite>
		<iisnode
                  node_env="production"
		  watchedFiles="*.js;node_modules\*;packages\*;routes\*.js;views\*.jade;middleware\*.js"
		  loggingEnabled="true"
		  devErrorsEnabled="true"
		  debuggingEnabled="true" />
    </system.webServer>
</configuration>
Clone this wiki locally