How to Deploy Ghost on Ubuntu 16.04
Using a Different System? Ghost is an open source blogging platform that is gaining popularity among developers and ordinary users since its 2013 release. I
Ghost is an open source blogging platform that is gaining popularity among developers and ordinary users since its 2013 release. It puts focus on content and blogging. The most attractive thing about Ghost is its simple, clean, and responsive design. You can write your blog posts from a mobile phone. Content for Ghost is written using the Markdown language.
In this guide we are going to set up and deploy a secure Ghost blog on an Ubuntu 16.04 VPS using Let's Encrypt, the latest LTS version Node.js, the latest mainline branch of Nginx, and latest version of Ghost.
Before starting this step, ensure that you have set DNS records for your domain.
We are going to use Let's Encrypt to obtain TLS certificates for our Ghost blog. Don't forget to replace all instances of example.com
with your domain name.
Update system:
apt update && apt upgrade -y
Install needed tools:
apt install -y zip build-essential
Install Let's Encrypt client:
apt install -y letsencrypt
Check version:
letsencrypt --version
# letsencrypt 0.4.1
Obtain certificate
letsencrypt certonly -d example.com -d www.example.com --email [email protected] --agree-tos --standalone
After going through previous steps, your certificate and private key will be in the /etc/letsencrypt/live/example.com
directory.
Ghost currently supports Node versions 0.12.x, 4.2+, and 6.9+ only.
We are going to install recommended version for Ghost which is v4 argon LTS
at the time of this writing.
Download and install the LTS version of Node.js:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
apt install -y nodejs
Check Node and NPM version:
node -v && npm -v
# v4.6.2
# 2.15.11
Download and install Nginx:
wget https://nginx.org/keys/nginx_signing.key && apt-key add nginx_signing.key
rm nginx_signing.key
printf "deb https://nginx.org/packages/mainline/ubuntu/ xenial nginx \ndeb-src https://nginx.org/packages/mainline/ubuntu/ xenial nginx \n" >> /etc/apt/sources.list.d/nginx.list
apt update && apt install nginx -y
Check Nginx version:
nginx -v
# nginx version: nginx/1.11.5
Start Nginx process:
service nginx start
Configure Nginx as a reverse proxy:
vi /etc/nginx/conf.d/ghost.conf
Paste the following in /etc/nginx/conf.d/ghost.conf
:
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:2368;
}
}
Check syntax:
nginx -t
Restart Nginx:
service nginx restart
If you want to host multiple Ghost blogs on same VPS, each Ghost instance must be running on a separate port.
Make webroot
directory:
mkdir -p /var/www/
Create a Ghost user:
adduser ghost
Download and install Ghost:
cd /var/www
wget https://ghost.org/zip/ghost-latest.zip
unzip ghost-latest.zip -d ghost
chown -R ghost:ghost /var/www/ghost/
rm ghost-latest.zip
Switch to the ghost
user:
su - ghost
Install Ghost:
cd /var/www/ghost
npm install --production
Configure Ghost by changing url
property of production
object inside of config.js
file:
cp config.example.js config.js
vi config.js
config = {
// ### Production
// When running Ghost in the wild, use the production environment.
// Configure your URL and mail settings here
production: {
url: 'https://example.com',
...
}
...
...
Save config.js
file and exit.
Start Ghost:
npm start --production
Ghost will now be running. Both blog front-end and admin interface are secured with HTTPS and HTTP/2 is working also. You can open your browser and visit site at https://example.com
. Don't forget to replace example.com
with your domain name.
If you close your terminal session with your VPS, your blog will also go down. That's not good. To avoid this, we are going to use the Forever process manager. That will keep our blog up 24/7.
Switch to ghost
user if you are not:
su - ghost
Go to ghost
folder
cd /var/www/ghost
Install Forever:
npm install forever
Add the new forever
command to your path:
echo "export PATH=/var/www/ghost/node_modules/forever/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
Start Ghost with forever:
NODE_ENV=production /var/www/ghost/node_modules/forever/bin/forever start index.js
At this point, forever
should have started Ghost.
Go to https://example.com/ghost
and create a Ghost admin account. Do this as soon as possible.
That's it. We now have a fully functional Ghost blog. If you want to change the default Ghost theme called Casper to a custom one, you can just download and unzip the theme into the /var/www/ghost/content/themes
folder and select it via Ghost admin interface, located at https://example.com/ghost
.
Gervigreind er ekki í framtíðinni, hún er hér í nútímanum Í þessu bloggi Lestu hvernig gervigreindarforrit hafa haft áhrif á ýmsa geira.
Ertu líka fórnarlamb DDOS árása og ruglaður með forvarnaraðferðirnar? Lestu þessa grein til að leysa spurningar þínar.
Þú gætir hafa heyrt að tölvuþrjótar græða mikið af peningum, en hefur þú einhvern tíma velt því fyrir þér hvernig þeir vinna sér inn svona peninga? við skulum ræða.
Viltu sjá byltingarkenndar uppfinningar frá Google og hvernig þessar uppfinningar breyttu lífi hvers manns í dag? Lestu síðan til að blogga til að sjá uppfinningar frá Google.
Hugmyndin um að sjálfkeyrandi bílar fari á göturnar með hjálp gervigreindar er draumur sem við höfum átt um tíma núna. En þrátt fyrir nokkur loforð eru þau hvergi sjáanleg. Lestu þetta blogg til að læra meira…
Þar sem vísindin þróast hratt og taka yfir mikið af viðleitni okkar, eykst hættan á því að verða fyrir óútskýranlegri einstæðu. Lestu, hvað sérkenni gæti þýtt fyrir okkur.
Geymsluaðferðir gagna hafa verið að þróast gæti verið frá fæðingu gagna. Þetta blogg fjallar um þróun gagnageymslu á grundvelli upplýsingamynda.
Lestu bloggið til að þekkja mismunandi lög í Big Data Architecture og virkni þeirra á einfaldasta hátt.
Í þessum stafræna heimi hafa snjallheimilistæki orðið afgerandi hluti af lífi. Hér eru nokkrir ótrúlegir kostir snjallheimatækja um hvernig þau gera líf okkar þess virði að lifa því og einfaldara.
Nýlega gaf Apple út macOS Catalina 10.15.4 viðbótaruppfærslu til að laga vandamál en svo virðist sem uppfærslan sé að valda fleiri vandamálum sem leiða til múrsteins á Mac vélum. Lestu þessa grein til að læra meira