Updated Note 4/2/19: While the information below is still valid, I’ve since moved away from ServerPilot and now use RunCloud. You can read my post as to why I switched here.
ServerPilot is great, and I recommend them to anyone. I use their service almost exclusively to manage multiple WordPress installations on a single $5/month DigitalOcean droplet. (If you’re not a super techy person, DigitalOcean may not be the best for you. In that case, I’d recommend BlueHost.)
After migrating off of shared hosting, ServerPilot provides a cPanel-esque-type GUI that makes managing multiple sites a breeze.
The problem, however, comes when you attempt to run an App that deviates from ServerPilot’s bread and butter: PHP or WordPress.
The largest issue is that ServerPilot runs a proprietary version of Nginx, which they’ve branded “Nginx-Sp”. Taking this into account, the setup is fairly straightforward once you learn how to work around those quirks.
Prep
The following steps assume that you have a DigitalOcean droplet connected to ServerPilot, and that you have already created a new app from within the SP admin panel.
While creating a new app, select whatever version of PHP you want (it doesn’t matter, since Ghost uses NodeJS as it’s server backend), and make sure you leave “WordPress” unchecked.
I entered the IP address of my droplet in the “Domain” section, as I don’t have a domain name. If you have one, enter it here.
Create a new user
The majority of these steps come straight from their documentation here: https://docs.ghost.org/docs/install
After creating a new App in ServerPilot, SSH to your server and create a new user.
adduser <user>
I named my user ghostinstall
, but you can name it whatever you want. You’ll have to assign a password to the new user. Just press Enter, skipping through all the ‘Name’ and ‘Room Number’ prompts. Next, grant your new user sudo permissions.
usermod -aG sudo <user>
Log in as new user and update server
su - <user>
sudo apt-get update
sudo apt-get upgrade -y
Skip Nginx and MySQL installs
At this point, the Ghost documentation wants you to install Nginx, configure firewall settings, and install MySQL. Ignore these steps. Nginx and MySQL are already installed. ServerPilot has taken care of this for us.
Install Node
The Ghost documentation has you install version 6, but let’s install the newer version (version 8). Ghost runs just fine on the newer version.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash
sudo apt-get install -y nodejs
Create database and user in ServerPilot
Head over to your ServerPilot admin panel, select your App, and create a new database and user. Obviously, choose something more secure than what I had shown below. ServerPilot will automatically attempt to generate a random username and password for you. Feel free to keep these if you want, but you’ll need them in a following step, so hang onto them.
Install Ghost-CLI
sudo npm i -g ghost-cli
Set folder permissions
The next steps are where I would always trip up. The Ghost documentation wants you to create a folder in the /var/www/ folder, but we know that ServerPilot holds your app in a different location.
Navigate to:
/srv/users/serverpilot/apps/<yourappname>
Then, chown
the folder using the user account we created earlier (in my case, it’s ‘ghostinstall’). We’ll use the recursive switch so we get both the current folder and the “public” subfolder as well:
sudo chown -R <user>:<user> .
Empty folder and install Ghost
Next, you’ll want to cd
to the public subdirectory:
cd public
Also, you’ll want to empty out this directory. By default, ServerPilot puts an index.php
file in the newly-created app directory. Ghost won’t install unless this folder is completely empty.
rm -rf *
The next step is crucial. The install wouldn’t continue until I did this:
sudo chown -R <user>:<user> /home/<user>/.config
Now, we can finally install Ghost:
ghost install
Configure blog settings
During the installation, it’ll ask you for your blog’s URL. Enter your domain name here. You must include “http” or “https”.
You can leave the MySQL hostname as localhost. It will then ask for the username, password, and database name that we created earlier.
When it asks if you want to create the Ghost MySQL user, you can enter Y
.
When the install asks if you want to set up Nginx, enter `n’, since we’ll be using ServerPilot’s version instead.
When the install asks if you want to set up Systemd
, enter ‘Y’.
The install will then do some database setup, and will end with a prompt, asking if you want to start Ghost. Of course, enter Y
.
Ghost should then start, but we’re not quite done yet. If you navigate to your URL, you’ll get a ‘Forbidden’ error message:
Edit .htaccess file
Create an .htaccess file:
touch .htaccess
Edit the file, and insert the following:
RewriteRule index.html http://localhost:2368/ [P] RewriteRule (.*) http://localhost:2368/$1 [P]
Save the file, close, and then restart Ghost by running ghost restart
.
Golden!
NOW you can hit your URL in a browser, and you should be greeted with the default theme and dummy content:
Browse to www.mydomain.com/ghost and follow the prompts to set up your blog and create a password.
Troubleshooting
If you run into any issues during the installation, you can simply do a rm -rf *
on the public
directory, and then restart the install by running ghost install
.
Thank you so much for sharing this method. I just started using Ghost and was wondering if there was some serverpilot/DO hack I could implement 🙂
Glad I could help! I was pulling my hair with this, so was happy to share.
Can you update your guide for RunCloud?
Ghost no work appropriately for the Runcloud. I did recent tests but without success.