Installing and Configuring Ghost with mysql and nginx
What is Ghost
Ghost is an opensource headless Node.js content management system. This post describes how to deploy ghost with mysql. for the mysql installation, please check the link below.
https://chainkindle.com/installing-mysql-5-7-on-centos-7/
apt-get update -y
Install node repo
we need to install the node repo, as this is necessary to install nodejs
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
#check version
npm -v
3.10.10
node -v
v6.14.3
Add ghost application user
In this post we defined the user as test. we will create a new user "test" has shown below and switch users to test for ghost installation.
adduser test
usermod -aG sudo test
su - test
Create the directory for Ghost
mkdir -p /var/www/ghost
chown test. /var/www/ghost
chmod 775 /var/www/ghost
Installation of Ghost-cli and Ghost
npm i -g ghost-cli@latest
cd /var/www/ghost/
ghost install
Nginx Configuration for Ghost
we would like to install letsencrypt certificate for our blog, and configure the reverse proxy for ghost. we use nginx as a webserver for ghost installation, this is shown in the steps below
server {
listen 80;
server_name chainkindle.com www.chainkindle.com;
access_log /var/log/nginx/chainkindle.log;
error_log /var/log/nginx/linuxerror.log;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 10G;
location / {
proxy_pass http://localhost:2369;
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_redirect off;
}
location ~ ^/.well-known {
root /var/www/linuxworld;
}
}
Letsencrypt setup
This is also done with the steps below
certbot --webroot certonly -w /var/www/chainkindle -d chainkindle.com -d www.chainkindle.com
ssl Configuration in our Custom Nginx configuration
upstream chainkindle {
server localhost:2369;
}
server {
listen 80;
server_name www.chainkindle.com chainkindle.com;
rewrite ^ https://$http_host$request_uri? permanent;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/chainkindle.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chainkindle.com/privkey.pem;
server_name www.chainkindle.com chainkindle.com;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 10G;
location / {
proxy_pass http://localhost:2369;
proxy_redirect off;
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_buffering off;
}
location ~ ^/.well-known {
root /var/www/linuxworld;
}
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
}
The website is now reachable on chainkindle.com as long as the domain records are already passed.