Ghost

From Newroco Tech Docs
Revision as of 09:21, 17 January 2022 by Lucian.pricop (talk | contribs)
Jump to navigationJump to search

Installation

First install mysql

apt-get install mysql-server

Open mysql and set a password for root

mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

And put the password in /root/.my.cnf

Install postfix

apt-get install mailutils

Install Node.js

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash
apt-get install -y nodejs

Install Ghost-CLI

npm install ghost-cli@latest -g

Install Ghost

mkdir -p /var/www/sitename
chown <user>:<user> /var/www/sitename
chmod 775 /var/www/sitename
cd /var/www/sitename
ghost install

Instalation questions:

  • Blog URL: http://blog.mydomain.com   (NOTE: I've used http because the encryption is done one the proxy, otherwise it will end up in a redirect loop)
  • MySQL hostname: localhost
  • MySQL username / password: root and password   (NOTE: it will use the root only to create a DB and a user with rights for that DB)
  • Ghost database name: blog
  • Set up a ghost MySQL user?: yes
  • Set up NGINX?: no   (NOTE: nginx will be used to proxy pass to the ghost port, but since we already have a proxy no need to use nginx)
  • Set up SSL?: no   (SSL is handled on the proxy)
  • Set up systemd?: yes
  • Start Ghost?: yes

The installer will give you a link to visit so you can finish the installation, but hold on that just a bit.

Edit /var/www/blog/config.production.json to make it listen on the VM's IP instead of just local

  "server": {
    "port": 2368,
    "host": "0.0.0.0"
  },

Edit the same file and configure ghost to use the local SMTP server to send emails

  "mail": {
    "transport": "SMTP",
    "options": {
       "hosts": "127.0.0.1",
       "port": 25,
       "tls": {
           "rejectUnauthorized": false
       }
    }
  },

Restart the ghost service

systemctl restart ghost_blog-mydomain-com.service

On the proxy point the domain to port 2368 instead of the default 80/443. The proxy vhost should look like this:

<VirtualHost *:443>
        ServerName blog.mydomain.com

        ProxyPreserveHost On

        RequestHeader set X-Forwarded-Proto "https"
        <Location />
            SSLRequireSSL
        </Location>

        ProxyPass / http://ip.add.rr.ess:2368/
        ProxyPassReverse / http://ip.add.rr.ess:2368/

        CustomLog /var/log/apache2/blog.mydomain.access.log combined
        ErrorLog /var/log/apache2/blog.mydomain.error.log

SSLCertificateFile /etc/letsencrypt/live/blog.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/blog.mydomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Now you can go to the link provided by the ghost installer at the end and finish the installation on the web interface

Theme development