What is Serverpilot?

It is a service that helps maintain your server automatically. Read more in this article that I wrote about connecting your server with ServerPilot - Managing a DigitalOcean Server With ServerPilot

What is this used for?

Serverpilot. calls all web sites that you setup on your server using ServerPilot, an 'app'.
Traditionally Serverpilot only supports php based apps but you can actually setup apps based on other programming languages as described here:


The most important take-away when setting up non-php apps on ServerPilot is:

If the instructions you're following are telling you to install or in any way configure Nginx or Apache, do not follow them! Instead, look for instructions that show you only how to install the app itself. It is safe to install packages that aren't web servers, such as nodejs, npm, ruby, python, pip, java, or perl.

Ok, let's do it! (in 5 quick steps)

① Have a quick glance at the tutorial "how-to-run-apps-in-any-language" mentioned above

② Download and Install the Node.js Source Code on your server, using these commands
(run as root or use sudo if you prefer to play it safe :)

curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
apt-get install -y nodejs

REMEMBER: Ghost prefers node.js version 4.x, (Node v4 argon LTS.) Read more here: http://support.ghost.org/supported-node-versions/

③ Copy or move over your ghost files using e.g. SFTP
(to install Ghost from scratch , see the bottom of this page)

all files need to go your apps 'public' directory on your server
e.g. /srv/users/serverpilot/apps/APPNAME/public

Replace APPNAME with the name of your app. You should make sure all files have serverpilots permissions. That can be done by running this command inside the public directory:

chown -R serverpilot:serverpilot *

④ Proxy Requests to Your Ghost App's Port
a) SSH or SFTP in to your server as the user the app belongs to (e.g., serverpilot)
b) create the file apps/APPNAME/public/.htaccess with the following contents (replace 2368 with the port your Ghost app is running on):

RewriteRule index.html http://localhost:2368/ [P]
RewriteRule (.*) http://localhost:2368/$1 [P]

An easy way to do this is to run this command as the serverpilot user:
nano .htaccess and then paste in above. REMEMBER, to change the port accordingly

IF you run above command as root, the new file will have root permissions. That isn't ideal. Instead you should make sure the .htaccess file has serverpilots permissions. That can be done by running this command:

chown serverpilot:serverpilot .htaccess

⑤ Start ghost by using this command in the public directory:
npm start --production


App Name - Choose a name that won't change later as you will NOT be able to change it. You'll have to delete the app and create a new one and when you delete an app Serverpilot deletes the entire app directory including all files that you have uploaded.

Starting Ghost - The command npm start --production only starts ghost from command line. It won't make sure that Ghost runs persistently after reboots. So follow these instructions to run Ghost persistently, including after server reboots:
How To Startup Ghost On Ubuntu 16.04 and Ubuntu 14.04 And Keep It Running
(article will be posted on January 26th)


Installing Ghost From Scratch

If you are installing ghost from scratch follow this tutorial:

That will work fine as long as you remember the caveats mentioned above, about not touching apache nginx web server files by yourself. Also, make sure you are installing the correct version of node.js.
Ghostforbeginners tutorial may be a little outdated and is using older install scripts.

You might want to read this other article I wrote about connecting your server with ServerPilot - Managing a DigitalOcean Server With ServerPilot

Reference Links:
Managing a DigitalOcean Server With ServerPilot