Hosting a site with Ghost CMS and EasyEngine v4. EasyEngine is a versatile tool to host WordPress sites in a containerized environment which makes it safe too. In this article, I will go through steps to using EasyEngine to host a site using Ghost.
I am using a local environment so my site will not have HTTPS and site name will be ghost.local
. Feel free to use it HTTPS and a real domain name.
Create a simple HTML site with EasyEngine.
ee site create ghost.local --type=html
Database for Ghost
In order to make Ghost stateful we will require a Database.
1. Let’s access EasyEngine’s database container with root user
docker-compose -f /opt/easyengine/services/docker-compose.yml exec global-db bash -c 'mysql -uroot -p${MYSQL_ROOT_PASSWORD}'
2. Create a database. Let’s name it ghost_local_db
MariaDB [(none)]> CREATE DATABASE ghost_local_db;
3. Let’s create a user named ghost_local_user
and password p@ssw0rd
and give the user access to the database created in the last step.
MariaDB [(none)]> CREATE USER 'ghost_local_user'@'%' IDENTIFIED BY 'p@ssw0rd';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON ghost_local_db.* TO 'ghost_local_user'@'%';
We are done with the Database part. Let’s create docker container for Ghost and make our site running.
Setup Docker containers and go live
1. Create a directory in the site directory. I will name it ghost
.
mkdir /opt/easyengine/sites/ghost.local/ghost
2. Create a docker-compose.yml file in that directory and add following content in it.
version: '3.5'
services:
ghost:
image: ghost:1-alpine
restart: always
volumes:
- "/opt/easyengine/sites/ghost.local/app/htdocs/:/var/lib/ghost/content"
environment:
# see https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables
database__client: mysql
database__connection__host: global-db
database__connection__user: ghost_local_user
database__connection__password: p@ssw0rd
database__connection__database: ghost_local_db
networks:
site-network:
aliases:
- ghost.local_ghost
global-backend-network:
networks:
site-network:
name: ghost.local
labels:
- "org.label-schema.vendor=EasyEngine"
- "io.easyengine.site=ghost.local"
global-backend-network:
external:
name: ee-global-backend-network
You can do a search-replace to and replace ghost.local
with your domain name in the above file.
Now we have to update the site Nginx configuration to pass the request to Ghost Docker container.
3. Open /opt/easyengine/sites/ghost.local/config/nginx/conf.d/main.conf
in an editor.
Remove everything from the file and add following in it.
server {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/htdocs;
server_name ghost.local;
index index.html index.htm;
location / {
proxy_pass http://ghost_ghost_1:2368;
}
include /usr/local/openresty/nginx/conf/custom/*.conf;
}
Replace ghost.local
in server name with your site name.
Alright we are done with all the configurations. Let’s go live!
Starting the Ghost container
Go to /opt/easyengine/sites/ghost.local/ghost
that we created in starting and run following command
docker-compose up -d
And restart the site with
# ee site restart sitename.tld
ee site restart ghost.local
Open your browser, hit your site and we are done.
Next step is to go http://ghost.local/ghost
in order to configure the site.
Accessing the files
Go to /opt/easyengine/sites/ghost.local/app/htdocs
to get access to contents of the site.
Before going in production
I strongly recommend to test the above in a local or development environment.
Please update the Nginx config too in order to verify everything is up to mark and safe.
I am not using Ghost. So, I can’t comment more on it. Feel free to contact me in case you run into some problems.
Cheers
Leave a Reply Cancel reply