Ghost install step by step

Ghost it's a free and open source app for create blog and websites, actually this website has built on this!

The installation isn't complicate but there's some things thak you need to know to work correctly.

Requirements

  • Host server
  • Docker
  • Apache
  • Domain name
  • Certbot

Installation

I'm assuming that you already have a host server, Docker and Certbot installed and a domain name. If you don't have a domain yet you can get one for free on this website.

Run Ghost Docker container whith an expose volume for the content:

docker run -d --name ghost --hostname ghost -v /external_path_to_ghost:/var/lib/ghost/content -e url=https://DomainName -p 3001:2368 ghost

Create Apache virtual host config file with proxy pass to make it reachable:

<VirtualHost *:80>
        ServerName DomainName
        DocumentRoot /path/to/ghost

        ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:3001/
        ProxyPassReverse / http://127.0.0.1:3001/

        ErrorLog ${APACHE_LOG_DIR}/DomainName-error.log
        CustomLog ${APACHE_LOG_DIR}/DomainName-access.log combined
</VirtualHost>

/etc/apache2/sites-available/DomainName.conf

Now what we need to do is to enable Apache virtual host, activate the proxy module and restart Apache service:

a2ensite /etc/apache2/sites-available/DomainName.conf
a2enmod proxy
systemctl restart apache2

At this point the website should be online, next step is to setup the https, i'm using certbot because it's free, fast and easy to configure:

certbot --apache -d DomainName

That's great! Now you have your Ghost online.

Load image fix

We don't finished it! I faced a problem when i tried to load images as described here, basicaly we need to add a missing header on vhost Apache config:

<IfModule mod_ssl.c>
<VirtualHost *:443>
	...
	RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
	...
</VirtualHost>
</IfModule>

/etc/apache2/sites-available/DomainName-le-ssl.conf

Now just need to activate headers module and restart Apache service:

a2enmod headers
systemctl restart apache2

Enjoy!