How to Run Ghost Blog Platform at IIS

2015/7/313 min read
bookmark this
Responsive image

This is about how to setup Ghost to run at IIS Web Server, you need to do following for setup Ghost at IIS. Following example is only tested at my Windows7 64bit, but it should be able to work fine at any other windows server.

Following instruction have tested on enviroments, Windows 7(64Bit) + IIS7, Windows Server 2012 R2 + IIS8

Setup Installation - Ghost at IIS 7

    1. Install node.js
      • selected 64-bit Windows Installer(.msi) 
      • Just following installation guide to install node.js, installed as v0.12.7
    2. Install IIS(7 or 8) 
      1. how to install IIS(IIS7 at Windows 10, Windows 8, Windows 7)
        1. windows + c, open Programs and features as command or go to control panel to open Programs and features.
    3. Install IISNode
      • installed iisnode for iis 7/8 (x64)
      • do a test to make sure iisnode installed correctly
        • go to /Program Files/iisnode
        • click setupsamples.bat, this batch file will tell you how to setup a sample website at IIS by using iisnode.
    4. Install Url Rewrite module
      1. Install URL Rewrite 2.0
    5. download ghost
      • downloaded v0.6.4 (2.4mb zip)
    6. unzip ghost folder and add all files and folder has IUser permission.
      1. move unzip folder to where you want to host your ghost application
      2. add IUser to be able to modify the entire ghost folder.
      3. You might have to add your local user to have modify permission to the folder.
        • I have specific error that tells /content/data doesn't have permission of my local user.
    7. add web.config at root folder
      • example location: /ghost-0.6.4/web.config
      • how to add web.config for ghost
      • if you want IIS site to run as Production mode, change <iisnode node_env="production"
        
        <configuration>  
          <system.webServer>
            <modules>
               <remove name="WebDAVModule"/>
            </modules>
            <handlers>
              <add name="iisnode" path="index.js" verb="*" modules="iisnode" />
            </handlers>
            <defaultDocument enabled="true">
              <files>
                <add value="index.js" />
              </files>
            </defaultDocument>
            <rewrite>
              <rules>
                <rule name="Ghost">
                  <match url="/*" />
                  <conditions>
                    <add input="{PATH_INFO}" pattern=".+\.js\/debug\/?" negate="true" />
                  </conditions>          
                  <action type="Rewrite" url="index.js" />
                </rule>
              </rules>
            </rewrite>
            <!--
              See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for information regarding iisnode specific configuration options.
              <iisnode node_env="%node_env%" loggingEnabled="false" debuggingEnabled="false" devErrorsEnabled="false" />
            -->
            <iisnode node_env="production" loggingEnabled="true" debuggingEnabled="true" devErrorsEnabled="true" />
          </system.webServer>
        </configuration>  
        
      • If you don't want to turn on logging, debugging, dev errors. turn following flg to false

loggingEnabled="true" debuggingEnabled="true" devErrorsEnabled="true" 

  1. add website and point to ghost rootfolder
    • example screen of site
    • since you can create as IIS site, you can change IP address, port number, HostName as how you setup iis site for .net site.
    • if you have domain name how to use, just like other site too. Change your "hostname" to point to the server's ip address and add the hostname to the IIS site.
    • You have to npm start --production, so npm will install all the dependency modules
    • Try npm start, check site is able to run at locally or not. 

At this point, you should be able to setup node.js site running by IISNode and is public to everyone.