How to install Ghost CMS via Docker on server with plesk control panel

Andy Wits Blog

How to install Ghost CMS via Docker on server with plesk control panel

When I try to install Ghost to server where Plesk panel is used, I found some problem. By default, Plesk server use 10.6.16-MariaDB, but ghost require Mysql, not MariaDB. Therefore we need install Ghost CMS via Docker.

There is main steps.

1. Plesk extensions and Domain

  1. Install "Docker" plesk extension https://YOURSERVER:8443/modules/catalog/index.php/catalog/package/docker

  2. Make domain via plesk panel + set ssl let's encrypt

  3. Install "Nginx" plesk extension (if not installed) https://YOURSERVER:8447/installer/add_components.html

  4. Check "Web hosting" > "Nginx web server and reverse proxy server"

  5. Start Nginx service on https://YOURSERVER:8443/admin/services/list

2. Install Docker Mysql Container

  1. Go to docker menu: https://YOURSERVER:8443/modules/docker/index.php/index/list?context=extNavButton_docker_1
  2. In the search box, type in "Mysql" and press enter
  3. You will see "Mysql" with the [OFFICIAL] tag. Click the highlighted arrow and choose the latest version
  4. This will download the image and bring you to the next screen.

3. Configure mysql Docker Container

  1. Container Name: Call this whatever you want, ideally something relating to your site. For this example, we're calling this "mysql8_container"
  2. Check the box for "Automatic start after system reboot"
  3. Un-check the box for "Automatic port mapping"
  4. Manual mapping: 3306 to external 3006, 33060 to 33060
  5. Specify mysql root via "Add variable" (for example): MYSQL_ROOT_PASSWORD == SomeSecurePhrase
  6. Proceed by "OK" button

4. Configure mysql database

  1. Connect to mysql console via ssh console: mysql -u root -p -P3006

  2. Execute this commands (for example) in order to create user & db for Ghost CMS:

 CREATE DATABASE exampledb;
 CREATE USER 'exampledbu'@'%' IDENTIFIED BY 'ExampleSecretPhrase';
 GRANT ALL ON exampledb.* TO 'exampledbu'@'%';
 FLUSH PRIVILEGES;
 EXIT (ctrl + D)

5. Install Docker Ghost Container

  1. go to docker menu: https://YOURSERVER:8443/modules/docker/index.php/index/list?context=extNavButton_docker_1
  2. In the search box, type in "Ghost" and press enter
  3. You will see "ghost" with the [OFFICIAL] tag. Click the highlighted arrow and choose the latest version by number (This may say 5.0.0 or similar. Do not choose "latest" or 5.x.x-alpine)
  4. This will download the image and bring you to the next screen.

6. Configuring Ghost Docker Container!

  1. Container Name: Call this whatever you want, ideally something relating to your site. For this example, we're calling this ghost_examplecom_container

  2. Check the box for "Automatic start after system reboot"

  3. Un-check the box for "Automatic port mapping"

  4. Manual mapping: 2368 to external 32778

  5. Volume mapping: "Container" placeholder: /var/lib/ghost/content "Host" placeholder: /var/ghost/ghost_examplecom_container/content (replace ghost_examplecom_container with your container name from the top of the page!

  6. Near the bottom of the page, click on "Add Variable"

  7. In the blank boxes, type "url" in the first box and your URL (eg: "https://example.com" in the second box (Make sure this domain is registered and added to Plesk)

Ensure that the database has been created first before proceeding. The information below is just sample data and should not be used!

  1. Add the database details: database__client - mysql database__connection__host - 172.17.0.2 (Your Docker internal network IP address) database__connection__user - exampledbu database__connection__password - "ExampleSecretPhrase" database__connection__database - exampledb database__connection__port - 3306

  2. Now click "OK" and let it install.

P.S. In order to access to Mysql db from one container to another, I can't found any solution...

But we check docker network and found: 172.17.0.2 - mysql8_container with 3306 port open 172.17.0.1 - ghost_examplecom_container

Well, we can use it!

7. Some settings to Proxy Requests from Domain to a Container

Go back to "Websites & Domains" and find your site, click on "Docker Proxy Rules"

Click "Add Rule" URL: Leave this alone Container: Choose your container Port: This should say 2368 -> 32778 Click "OK"

9. Questions:

  1. How do access the files if I want to import themes or other content? Connect via SSH to your server (FTP will not work) /var/ghost/ghost_examplecom_container/content/

  2. What if I want to run a 2nd or 3rd Ghost blog on Plesk? Repeat the steps above, the only thing to change are: The "Container Name" The port, change it from 32778 to 32779

  3. What if I want it at example.com/blog? Indicate this in the url on the setup page. And when you add it in the rule on the "Docker Proxy Rules" page, add blog where it says "URL"

  4. I want to move this to/from a subdomain from/to a naked domain? Go into the "Docker Proxy Rules" and remove the rule from here. Go into "Docker" on the left-hand side. Click on "Settings" beside the container and adjust the url in here. This will more than likely restart the container. Re-add the "Docker Proxy Rules" to the new subdomain or naked domain.

10. Useful Links:

  1. https://ghost.org/docs/install/
  2. https://padraig.blog/how-to-install-ghost-5-on-plesk-obsidian/
  3. https://docs.plesk.com/en-US/obsidian/administrator-guide/plesk-administration/using-docker.75823/
  4. https://www.plesk.com/kb/support/how-to-proxy-requests-from-domains-to-docker-container-in-plesk/
Published on May 01 2024 at 5:07 am
Time to read 5 minute(s)
Categories
  • System Administration

Contact me on