Install ghost with docker + MySQL 8 [New Install]
Ghost is dropping support for MySQL5 for the next major release. If you are thinking to install ghost 4.x.x via docker choosing MySQL 8 would be a wise decision to avoid issues with future updates of the ghost version.
Ghost is already pushing a notice to, those who are currently using MySQL 5 to upgrade the MySQL version
Without further delay let's jump on to the tutorial. To install ghost with docker make sure you have docker & docker-compose installed in your system.
to install docker on your system follow the guide (We are using Ubuntu 20.04 for the tutorial)
Step 1: Creating the Docker Compose File & start the Container
Access to your Server via Terminal
your-server-user@your-server-ip-or-host
Create a folder to contain the docker-compose.yaml
& docker volumes.
cd
mkdir yourdomain.com
Create a file called docker-compose.yaml
into the folder, you have just created
nano docker-compose.yaml
& paste the following
version: '3'
services:
ghost:
container_name: yourdomain.com
image: ghost:latest
restart: always
ports:
- 2368:2368
volumes:
- ./content:/var/lib/ghost/content
environment:
url: https://www.yourdomain.com
database__client: mysql
database__connection__host: db
database__connection__user: root
database__connection__password: mysqulrootp@ssworD
database__connection__database: yourdomain_prodction
mail__transport: SMTP
mail__from: "YourSite <name@yourdomain.com>"
mail__options__host: "smtp.sendgrid.net"
mail__options__port: 587
mail__options__auth__user: "apikey"
mail__options__auth__pass: "sendgrid_api_key"
db:
container_name: yourdomain_db
image: mysql:latest
command: mysqld --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: mysqulrootp@ssworD
volumes:
- ./data:/var/lib/mysql
Adjust the container_name
url
databas__connection__pasword
database__connection__databse
& SendGrid API
with your original credentials, Save the file by pressing Ctrl+O
.
Now start the container. run the following command to start the container.
docker-compose up -d
Step 2: Configure Nginx Server Block
sudo apt install nginx
Create a file in /etc/nginx/sites-available/
directory using the following command.
sudo nano /etc/nginx/sites-available/yourdomain.com
& paste the following
server {
listen 80;
listen [::]:80;
server_name yourdomain.com www.yourdomain.com;
location / { return 301 https://yourdomain.com$request_uri; }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yourdomain.com www.yourdomain.com;
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_certificate /etc/ssl/domainn/cert.pem; #define your ssl cert path
ssl_certificate_key /etc/ssl/domain/key.pem; #define your private key path
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://0.0.0.0:2368; #define the port as your container
}
}
Save the file by pressing Ctrl+O
& exit
Next, we have to create a symlink of the file to sites-enabled
directory.
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
check the Nginx configuration
sudo nginx -t
restart Nginx
sudo systemctl restart nginx
Now your blog should be up & running. Hope this helps.