Quick note: You can choose which ever VPS provider (AWS, DigitalOcean, ...) you'd like, it's almost the same for all of them.
I'm going to base this guide on the official documentation where they use:
NGINX (minimum of 1.9.5 for SSL)
Node v6 installed via NodeSource
At least 1GB memory (swap can be used)
A non-root user for running ghost commands
This is the setup that Ghost CLI is intended for & tested against, and is the only setup that they guarantee will work out of the box. Ghost CLI is designed to be extensible in the near future, however if you choose to use alternatives to our recommended stack you should expect to have to debug & fix problems yourself.
This guide assumes that you have the following:
- An Ubuntu 16.04 server, configured with a non-root user with sudo privileges, as described in the initial server setup guide for Ubuntu 16.04.
- A domain name pointed at your server's public IP, as per How to Set Up a Host Name. This tutorial will use example.com throughout.
Run the following to ensure Ubuntu is up to date. This will take a few minutes.
sudo apt-get update && apt-get dist-upgrade -y
You will likely be asked the following: "A new version of /boot/grub/menu.lst is available, but the version installed currently has been locally modified. What would you like to do about menu.lst?" Just press enter and choose the default, "keep the local version currently installed".
Log in as the new user
su - arturo
Install some needed libraries. Add to the list anything you may want.
sudo apt-get install -y unzip build-essential libssl-dev git nginx mysql-server
Open Firewall for HTTP/HTTPS
sudo ufw allow 'Nginx Full'
Add the NodeSource APT repository for Node 6
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash
sudo apt-get install -y nodejs
sudo npm i -g ghost-cli
Create a new folder
sudo mkdir -p /var/www/ghostBlog
Your user must own this directory
sudo chown arturo:arturo /var/www/ghostBlog
Where [arturo] is the user you created during the setup phase.
Your installation folder must have the correct permissions
sudo chmod 775 /var/www/ghostBlog
Navigate to the new folder
Install Ghost (using Ghost-CLI)
This will install and start your blog in production mode using MySQL as the default database
You will be prompted for the following pieces of information:
Enter your blog Url:
This is the url your blog will be available at and must include the protocol. e.g
http://myblog.com for HTTP or
https://myblog.com for HTTPS.
Enter your MySQL hostname [localhost]:
This determines where your MySQL database can be accessed from. For the most cases the user installs MySQL on the same server, in this case use localhost (press [enter] to use the default value).
Enter your MySQL username:
Enter your MySQL username. If you have already created a mysql user, password and database with the correct credentials ready for Ghost, enter those details now. Else, enter root and your MySQL root password and Ghost will generate a custom MySQL user for you.
Enter your MySQL password: [hidden]
The password for the MySQL user you entered in the previous step
Ghost database name:
Press [enter] for default
Do you wish to set up a ghost MySQL user?
If you provided your root MySQL user, Ghost CLI can create a custom MySQL user that can only access/edit your Ghost database. This is recommended, and Ghost-CLI takes care of this for you if you accept.
Do you wish to set up nginx?
Sets NGINX up for your blog enabling it to be viewed by the outside world. You can optionally set this up yourself.
Do you wish to set up ssl?
If you do not already have a valid ssl certificate installed for your blog and wish to use secure protocol, Ghost-CLI can take of this for you using the Let's Encrypt certification service. Otherwise you have to setup ssl by your own.
Your domain must have resolved to your server in order for the SSL setup to work. If you choose no now, you can run ghost setup ssl later to rerun this step.
Enter your email (used for SSL certificate generation)
This is required for SSL certification so that you can be kept informed if there is any issue with your certificate such as requiring renewal.
Do you wish to set up systemd?
systemd is the recommended process manager tool for keeping Ghost running. Choose yes to have it configured for you, or no if you're happy setting up process management yourself.
Do you want to start Ghost?
Choose whether you want to have Ghost running right away.
What to do when an install fails
If an install goes horribly wrong, you can use
ghost uninstall to remove it and try again.
Login to setup the root account:
If at somepoint your nodejs starts listening in a different port, check the port is using and assign it to the nginx config, check the port number with:
sudo netstat -plnt
Check out this Index page