How to setup WordPress on Synology Docker

WordPress is the most used blog platform, but is it the best?

How to setup WordPress on Synology Docker
Photo by Stephen Phillips - Hostreviews.co.uk / Unsplash

WordPress is the easiest blogging platform to host, so why not selfhost and use your own domain without paying extra for that feature?
Synology has an existing package for WordPress, should you use that? Or what if you have more than 1 webpage to host? You might even consider using the new mulit-site feature on WordPress.
Otherwise, here's how you can set it up on Synology Docker.

Prerequisites

  1. Go to Package Center and install Docker
  2. Go to File stations and navigate to Docker folder
  3. Create two folders, wp-app and wp-db
  4. Open Docker on Synology and select Registry tab
  5. Search for WordPress and MySQL, download both with latest tag
    Screenshot-2023-02-08-101943
  6. Buy me a drink on Ko-fi :)

Create MySQL Container

  1. Go to Container tab and Create a Container:
    1. Select Image: mysql
    2. Network: bridge
    3. Container Name: wp-db
  2. Go to Advanced Settings
  3. Add the following Enviroment variables:
    1. MYSQL_ROOT_PASSWORD = mysqlrootpassword
    2. MYSQL_DATABASE = wp
    3. MYSQL_USER = wpuser
    4. MYSQL_PASSWORD = wppass
  4. Review, click Save, then Next
    Screenshot-2023-02-08-102225
  5. Leave the Port settings as default, click Next
  6. Click Add Folder, navigate to the wp-db folder
  7. Add the mount path as /var/lib/mysql
    Screenshot-2023-02-08-102301
  8. Click Next and Done

Before you continue, be sure to check that the DB is ready. This should take ~5 mins.
While waiting, go to Prerequisites Step 6.

  1. Double-click the Container and go to Logs tab
  2. Look for the line that says /usr/sbin/mysqld: ready for connections.

Create WordPress Container

  1. Go to Container tab and Create a Container:
    1. Select Image: wordpress
    2. Network: bridge
    3. Container Name: wp-app
    4. Enable auto-restart
  2. Go to Advanced Settings
  3. Add the following Enviroment variables:
    1. WORDPRESS_DB_HOST = wp-db
    2. WORDPRESS_DB_USER = wpuser
    3. WORDPRESS_DB_PASSWORD = wppass
    4. WORDPRESS_DB_NAME = wp
      Screenshot-2023-02-08-102456
  4. Select Links tab and click Add
  5. Select the Container name that you've created for MySQL, eg. wp-db
  6. Click Save, then Next
  7. Set the Local Port to 8080, click Next
  8. Click Add Folder, navigate to the wp-app folder
  9. Add the mount path as /var/www/html
    Screenshot-2023-02-08-102634
  10. Click Next and Done

Go get a coffee and send me a tip as this will take at least 5 mins and if you go to your NAS IP Address with the port you've defined above on a browser, eg. http://192.168.1.10:8080
You'll be greeted WordPress installation screen.
Screenshot-2023-02-08-103009