Refers:
https://docs.ghost.org/docs
https://ghost.org/Ubuntu 16.04 is recommended as your server OS.
If you are first login into your blog server,
Please Create a New User and Give Super User Privileges as well.
$adduser <user>
$usermod -aG sudo <user>
$su - <user>
Install Pre-requisites:
$sudo apt-get update
$sudo apt-get upgrade
#nginx
$sudo apt-get install nginx
$sudo ufw allow 'Nginx Full'
$sudo apt-get install mysql-server
#Warning
During mysql installation, you will be prompted to create a root password. Please ensure that you actually specify a value for this, as leaving the root password blank will make Ghost-CLI unable to connect to the database.
#Adding swap memory if needed
If your system has less than 1GB memory, you may run into errors. To overcome this, configure a larger amount of swap memory:
$dd if=/dev/zero of=/var/swap bs=1k count=1024k
$mkswap /var/swap
$swapon /var/swap
$echo '/var/swap swap swap default 0 0' >> /etc/fstab
#nodejs
$curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash
$sudo apt-get install -y nodejs
#install ghost-cli
$sudo npm i -g ghost-cli
#install ghost
$sudo mkdir -p /var/www/ghost
$sudo chown [user]:[user] /var/www/ghost
$cd /var/www/ghost
$ghost install
#The CLI will asks you for the minimum required 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.
If you want to setup SSL, your domain must already be pointing at your server. If your domain is ready and resolved, then you can enter the https version of your domain, and choose "yes" later when asked if you want to setup SSL.
If your domain is not yet ready, enter the http version of your domain and choose no when prompted about SSL. When your domain is resolved, you can run ghost config url [https domain] && ghost setup ssl to run the ssl setup.
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:
Here you have to enter the name of your database. If you install multiple instances of ghost on your server you need to specify a different database for each instance. If the database you entered does not exist already and you provided your root credentials it will be created for you.
If you pass a non-root MySQL username and password, this database must already exist and your user must have privileges for this database.
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.
#Once install done, let's start your blog.
$ghost start
Then you can open your blog url via any web browser. e.g. my blog:
https://errong.win
You can login into your ghost blog via https://[blogurl]/ghost
e.g. my blog ghost admin area.
https://errong.win/ghost