Nahum Shalman

Ghost on SmartOS

  1. Get a separate account set up for ghost to use

    echo ghost:x:5001:5001::/opt/ghost:/bin/false >> /etc/passwd
    echo ghost::5001: >> /etc/group
    
  2. Exctract the zip file

    unzip ghost-0.3.3.zip -d /opt/ghost
    cd /opt/ghost
    npm install --production
    cp config.example.js config.js
    chown -R ghost:ghost .
    
  3. Tweak config.js as appropriate
  4. Create a manifest with manifold (Here's the one I created. Note the tweak to alter the NODE_ENV):

    <?xml version="1.0"?>
    <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
    <!--
            Created by Manifold
    -->
    <service_bundle type="manifest" name="ghost">
      <service name="site/ghost" type="service" version="1">
        <create_default_instance enabled="false"/>
        <single_instance/>
        <dependency name="network" grouping="require_all" restart_on="error" type="service">
          <service_fmri value="svc:/milestone/network:default"/>
        </dependency>
        <dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
          <service_fmri value="svc:/system/filesystem/local"/>
        </dependency>
        <method_context>
          <method_credential user="ghost" group="ghost"/>
        </method_context>
        <exec_method type="method" name="start" exec="/opt/local/bin/npm start" timeout_seconds="60">
          <method_context>
            <method_environment>
              <envvar name="NODE_ENV" value="production"/>
            </method_environment>
          </method_context>
        </exec_method>
        <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60"/>
        <property_group name="startd" type="framework">
          <propval name="duration" type="astring" value="child"/>
          <propval name="ignore_error" type="astring" value="core,signal"/>
        </property_group>
        <property_group name="application" type="application">
          <propval name="config_file" type="astring" value="/opt/ghost/config.js"/>
        </property_group>
        <stability value="Evolving"/>
        <template>
          <common_name>
            <loctext xml:lang="C">
                        Ghost Blogging Software
                    </loctext>
          </common_name>
        </template>
      </service>
    </service_bundle>
    
  5. Configure nginx to proxy your connections

    server {
        listen       80;
        server_name  blog.shalman.org;
        location / {
            proxy_set_header Host $host;
            proxy_pass http://localhost:2368;
        }
    }
    
  6. Bounce nginx, launch ghost!

    svccfg import /opt/ghost/ghost.xml
    svcadm restart nginx
    svcadm enable ghost
    
smartos ghost