WordPress installation on Synology box

For the past few days I have been struggling to install WordPress (manually, rather than using the Synology Wordpress package, so that I can have multiple sites) on my Synology 216-Play box, and hit many problems which I have managed to work my way through (or round) using tips from various internet forums, and the excellent musings of 'Sridhar' on his blog https://sridhar.blog/install-multiple-wordpress-sites-synology-nas/

He admits that his blog does not tackle the problem of access from outside your local network, which I was keen to do, so what follows is a combination of Sridhar's suggestions along with some of my own which together seem to work.

I don't guarantee that they will work for you, but I hope they might give you some help if ever you want to try the same.

There were quite a few unforeseen problems along the way, many down to the odd quirks in the Synology software, so if you want to read my solutions to those, please read the following posts which will appear shortly.

Many thanks,

Robert Eadie

Problems along the way

Firstly, the various problems I came up against.

  • Whatever I tried, I kept on getting Server 500 errors whatever I tried at the WordPress installation.
    • Most suggestions are to try 'localhost' or 127.0.0.1 as the hostname of your database (assuming it is on the Synology box).
    • The only thing that worked for me using MarioDB 10,  was 'localhost:/run/mysqld/mysqld10.sock'
    • Many thanks to whose comments on Sridhar's musings got me past that barrier.
  • Wordpress itself needs direct FTP access to each of your sites, if you ever want to install new Themes, or plugins, or . . .
    • That means that each site needs a separate user, and each of those users needs direct FTP access to the wordpress folder for that site.
  • Synology does not make it easy (or even possible) to create a shared SUB-folder, nor to point web site root to a user home folder (which would have been easier).
    • That resulted in my deciding to create a new shared folder (at the top level) to hold the wordpress software for each of my sites.
  • You will of course need to access your Internet Router and setup 'Port Forwarding' both 80/443 for web traffic, and 21 for FTP, to your Synology box.  I have a BT Home Hub on which it is very straightforward, but see my detailed post shortly!

External access to your web site on Synology

Your Synology box probably has an Internal IP address which can only be accessed from machines on your internal network.  If you want access from external devices, anywhere on the Internet, then you need to 'map' the external IP address of your Router to the Internal address of your Synology.  You also need to map a 'nice' hostname (e.g. eadie.ddns.net) to that external IP address, so that users don't have to remember an IP address.

Mapping an External IP to and Internal IP address.

This is normally referred to as 'port forwarding' and needs to be set up on your router.  You need to set up port 80 (for http) and if required 443 (for https).  Also, if you want to be able to install new Themes and Plugins, and update them, once you have Wordpress installed, you will need port 21 for FTP.  I can't go into all the details for every router, but on my BT Home Hub 5 it was fairly obvious from the Admin - Advanced menus.  (Check your router manual!).

Mapping a hostname to your external IP address.

This is known as setting up a DNS record, pointing your nice hostname (e.g. eadie.ddns.net, or your own personal domain) to an IP address.
The first problem is that most domestic broadband connections do not keep the same external IP address for ever, as your ISP can change it (at their convenience) from time to time.  If this applies to you, then you have two options:
  • Buy a fixed IP address (from your ISP), or
  • If you're like me and are trying to do thing 'for free' (which is why I'm trying to set up my website on my Synology, so that I don't pay for hosting) then you need to set up a 'Dynamic DNS system' which will constantly keep track of your external IP address, and change the DNS setting as the IP address changes.

Dynamic DNS (DDNS)

There are several Free Dynamic DNS providers, and I have tried a few, such as NoIP, DtDNS, FreeDNS, etc.  They offer slightly different services (for free), but you will also have to set up on an internal machine, an automatic system which will constantly tell them what your external IP address is.  You can do this on:
  • Your PC or MAC,
    • This will of course only work while your computer is on, so if your IP address changes overnight, that won't be flagged up until the next morning, or if you go away for several days and switch your computer off . . . .
  • Your Synology box,
    • Seems ideal, except that the Synology software (for some strange reason) only allows ONE URL/hostname for each DDNS provider you use.  So if you want four websites/hostnames, you will need to register with four DDNS providers.
    • (I have no idea why this limitation is built into my Synology box, and I may have done something wrong, but . . .)
  • Your router.
    • This seems the ideal, as most people's router is on 24/7, but on my BT Home Hub, I can only use ONE DDNS provider, so if I hit the limit of their maximum hostnames for their free service, I can't add more from another provider.
    • This limitation and the Synology limitation conspire to make things more awkward than they ought to be (but we're here to try to overcome these problems!).  At the moment, for testing purposes, I have three (from the same provider) set up on my router, and two (from two different providers) on my Synology.  If you want to go much beyond that, I suggest you start paying for your DDNS!
Again, setting up on the Synology (Control Panel - External Access - DDNS) or your Router is fairly straightforward.  You will need to enter your login details for the DDNS provider, and the hostname(s) you've chosen.  Both should show you whether they are successfully working.

Wordpress install

Now to the actual install on the Synology box.  Mine is a DS216play.
  1. Install Synology packages
  2. Prepare Wordpress software
  3. Create user and folder
  4. Setup external http and ftp access
  5. Create Database
  6. Setup Wordpress using Web Station
  7. Initialise and test!

Install Synology packages

Install Web Station (this creates a ‘web’ folder ready for your web sites, but for reasons below I can’t use this folder for my Wordpress sites), Apache 2.2 and 2.4 (why?), MariaDB 10, PHP 5.6 and 7.0, phpMyAdmin (and Wordpress?).  Actually Wordpress installs some of these dependencies anyway, so perhaps install that first to see which it does.  We’re not going to use the Wordpress package anyway but set things up manually.

Prepare Wordpress software

  1. Using File Station create a folder on your site for the latest Wordpress package, call it something like ‘Wordpress Software’.  Keep this software ‘unused’ so it is available to start building any other new sites you want.
  2. Download the latest Wordpress version, unpack it, and copy the contents into this new folder (there should be three folders, ‘wp-admin, wp-content, wp-includes, and several files mostly php files).  There are two methods of doing this:
    1. Install the Download Station on your Synology, set its destination folder as your new folder for the software, and download from http://wordpress.org/latest.zip, then unpack on the Synology using the context menu for the zip file, or
    2. Download to your PC, unpack, and upload the contents up to the folder using File Station or an ftp client such as WinSCP.  (I found problems uploading folder using Filestation, and didn’t want to use ftp, so used option 1 above.)
  3. Use File Station to copy all this software (3 folders and files) into the folder ‘test’ you created above.

Create User and Folder

I discovered that to install new themes, plugins, and updates etc., Wordpress needs external ftp access to your Wordpress folder which gives us a Synology problem!

You need to give Wordpress a unique user/pw for each of your Wordpress sites, which will then have direct access to the folder where your Wordpress files are.  On the Synology that means that your folder needs to be a direct shared folder (you can’t share a subfolder, at least without some coding trickery!).  It can’t be a user Home folder, as Web Station cannot use those as the root of a web site.

My solution was to create a new user for each web site I wanted, and a new shared folder (at the top level, it’s the only way you can create a shared folder!!) and point the new user ftp root to this new share.  In my case:
  1. New user ‘test’
  2. New shared folder ‘test’
  3. Give ‘test’ and ‘http’ read/write permissions to test folder
  4. Using Control Panel – File Services – ftp
    1. Enable FTP, and
    2. under advanced – direct user ‘test’ ftp root to shared folder ‘test’.

Setup external http and ftp access through your router

See my more detailed post on setting up External Access, or if you're confident here's a summary.
I’m not sure why Synology will only allow one DDNS setting for each DDSN provider, but it does mean that if you want to run four sites, you need four DDNS providers.
  1. Setup DDNS on Synology.
    1. Register with one of the (free) DDNS services (‘No-ip’ in my case)
    2. eadietest.ddns.net = 89.1235.110.79
  2. On your Synology Control Panel – External Access – DDNS
    1. Add your new DDNS service provider, hostname, login details, and external (router) IP
  3. Setup ‘Port Forwarding’ on your router
    1. Usually ports 80 and 443 incoming, route to the INTERNAL Ip address of your Synology box

Create Database

Log into your phpMyAdmin (at http://<yoursynologyIPAddress>/phpMyAdmin, and on my box I HAVE to use the capital ‘M’ and ‘A’ – phpmyadmin does not work!) , using ‘root’ as the username and a blank password.  CHANGE THE ‘root’ PASSWORD NOW for security!
  1. Create a new database for your site, eg ‘test’
  2. If you don’t want to use ‘root’ for Wordpress to connect to this new database, with your new database select ‘privileges’ and add your new user (in my case ‘test’) and give it all privileges on your new database.
    1. I couldn’t get this working correctly, so lazily just use ‘root’ for Wordpress to connect to my database.

Setup your new site using Web Station

Launch Web Station
  1. General Settings: Set HTTP back-end server to Apache 2.4 and PHP 7.0
  2. PHP Settings: Set PHP version to 7.0, leave cache enabled
    1. select at least these extensions: curl, exif, ftp, gd, gettext, iconv, mcrypt, mysqli, openssl, posix, soap, sockets, xmlrpc, zip. (I was lazy and enabled ALL extensions!)
    2. Press Apply.
  3. Virtual Host: Click Create
    1. enter your new external website name (eg ‘eadietest.ddns.net’) for hostname
    2. browse to your site’s folder for Document root
    3. select Apach HTTP 2.4 and PHP 7.0
    4. press OK.

Initialise and test

I personally don’t like messing with wp-config files, and prefer to let Wordpress set itself up so
  1. Use a browser to go to your new site using the external address (assuming that your PC uses your router as DNS server) eg eadietest.ddns.net - Wordpress should prompt that it is going to ask you database settings and initialise.
    1. Database name: your new database
    2. Username: either root, or your new ‘test’ user (if you can get this to work)
    3. Password: either for root or test
    4. Hostname: localhost:/run/mysqld/mysqld10.sock
      1. This is critical, as far as I can tell, and was the only way I could get rid of the pesky ‘server error 500’ if I just used ‘localhost’ or 127.0.0.1’.
    5. Table prefix: I left it as wp_ as I am going to use a separate database for each site.
If things have gone well, you should get a congratulatory message (echoed by me for working through all these instructions!!) and be able to use Wordpress itself to do the configuration, choose theme, etc.

Good luck, and do let me know how you get on.
Robert