Install Ghost Blog on IIS

Install Ghost Blog on IIS

Pre Condition

Ghost's current recommended Node version is Node v10 LTS. Also 8.x (Node v8 Carbon LTS) is supported
IISNode is installed, including IIS URL Rewrite Module

First of all, we need to install the ghost CLI:

npm install -g ghost-cli@latest

Create a new empty folder
mkdir ghost

Change directory into the folder
cd ghost

For Development e.g. macOS


Install local environment via ghost cl

ghost install local

Open Browser and navigate to
http://127.0.0.1:2368

Production


Set production mode via environment variable

set NODE_ENV=production

Install Ghost and create a default configuration

ghost install --db sqlite3 --no-prompt --no-stack --no-setup --dir .
cd .
ghost config --ip 127.0.0.1 --port 2368 --no-prompt --db sqlite3 --url https://blog.mydomain.de

Run the database migrations for validation of database tables

ghost setup migrate

Adjust the config file (config.production.json)
Remove the port because it will be injected via IISNode and environment variable

{
  "url": "https://blog.mydomain.de",
  "server": {
    "host": "127.0.0.1"
  },
  ...
}

Test the actual config

set server__port=2368

and run a new node process via terminal

node current/index.js

If the server starts and you can open it via Browser under http://127.0.0.1:2368, stop the Process with Strg and C

Index and web.config for IISNode
Create an index.js file in your ghost root folder including:

process.env.server__port = process.env.PORT;
require('./current/index.js')

So you are able to inject the port for the IIS dynamically

Also you need to create web.config for IIS:

<configuration>
	<system.webServer>
		<modules>
			<remove name="WebDAVModule" />
		</modules>
		<handlers>
			<clear />
			<remove name="WebDAV" />
			<add name="iisnode" path="index.js" verb="*" type="" modules="iisnode" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
		</handlers>
		<iisnode node_env="production" enableXFF="true" nodeProcessCountPerApplication="1" />
		<rewrite>
			<rules>
				<rule name="ghost">
					<match url="/*" />
					<action type="Rewrite" url="index.js" />
				</rule>
			</rules>
		</rewrite>
	</system.webServer>
</configuration>

IIS Configuration
Finally create a new site in your application pool with the binding to your domain e.g.
 https://blog.mydomain.de

and add the physical path to the ghost root folder.

And now ghost should run under your domain!

Adding new content

Check out the admin tools for adding new content to your blog:

https://ghost.org/downloads/

The End
If you found any problem following the tutorial, please leave your comment below.

If this post was helpful, please click the  ❤️ and ? button below a few times to show your support! ⬇⬇