Home About Me

What It Took to Run a WordPress Blog From a Synology NAS

A Synology NAS is the starting point. NAS mostly means network storage: a personal cloud whose server sits at home. Once it is set up, every device on the Wi-Fi—desktop, laptop, phone, tablet—can reach it and share files. That removes a lot of copying back and forth. If a movie has just finished downloading on the computer, you can put it on the NAS and open it from your phone without hunting for a cable. A NAS can do more than store files, too. It can act as a simple server for lightweight jobs, including a blog hosted at home.

I used a Synology DS214play. By June 7, 2018, the newer model was apparently the DS218play, and the DS214play had already been discontinued. The DSM version at the time of setup was DSM 6.1.7-15284.

Many tutorials I found had settings that no longer matched current DSM, so I kept getting stuck. I spent about a week of evenings checking documentation and trying again. Some of the settings below may change with future Synology updates; this is a record of what worked then.

Install the blog software

There are several blog programs, such as Z-Blog and emlog, but WordPress is the most widely used. I prefer popular software because there are more tutorials and more people reporting solutions when something breaks.

From Synology’s Package Center, install these three packages:

  • Web Station
  • phpMyAdmin
  • MariaDB 10

MariaDB may now ask you to set a password during installation. Remember the username and password.

After Web Station is installed, File Station shows a web folder.

The web folder created by Web Station

I mapped that folder on my computer so it was easier to work with.

Mapped web folder on a computer

Now download WordPress. Search for the official WordPress site, go to the Chinese official download page, and get the WordPress archive. Do not install WordPress from Synology’s Package Center. It looks convenient, but it cannot update automatically, and later external-access setup can run into problems.

Downloading WordPress

Put the archive into the web folder and extract it. You should get a folder named wordpress.

The extracted WordPress folder

That wordpress folder is the blog site.

Next, set read/write permissions on the wordpress folder. Without this, installation can fail, and after installation you may be unable to install new themes.

In File Station, open web, find wordpress, right-click it, and open Properties.

Opening the WordPress folder properties

Go to Permission. Change all HTTP permissions to Read & Write. At first they may be greyed out, so go to Advanced and choose Make inherited permissions explicit.

Making inherited permissions explicit

The permissions should then look like this.

HTTP permissions set to read and write

Open http://NAS-IP/phpMyAdmin/ in a browser. The capitalization matters.

phpMyAdmin login page

If you already set a password, enter it. If not, leave it blank. It is better to change the password right away: if you change it after installing the blog, access can break, and you will have to edit the DB_PASSWORD line in wp-config.php to match.

Once inside phpMyAdmin, create a database for the blog. I named mine wordpress, but the name can be anything as long as you remember it. Choose collation utf8_unicode_ci.

Creating the WordPress database

Open Web Station, then Virtual Host, then Create. This was my configuration.

Virtual host configuration

The port number is arbitrary; I used 666. The document root must point to the folder where the blog program lives. Make sure HTTP and PHP are checked.

Then go to PHP Settings, double-click the Default Profile, and tick all extensions. On newer DSM versions this is required. Older versions did not need it, and that difference cost me a lot of time.

Now install the blog. Open http://NAS-IP:666/ and follow the prompts.

WordPress installation screen

Enter the username and password. For the database host, I used 127.0.0.1:3307. Earlier, localhost worked for me, but later it did not. If one fails, try the other.

Database host during WordPress installation

Submit and continue. If it works, the blog is installed. If not, recheck the earlier steps and look up the error.

At this point the blog is available at the NAS IP address plus the port number.

After installation, updating the site, themes, or plugins may ask for FTP credentials. This usually means PHP does not have write permission. Add this to the end of wp-config.php:

define("FS_METHOD", "direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);

Later feedback suggested that this FTP workaround can stop working in some setups, so a different fix may be needed depending on the DSM and PHP version.

Set up external access

After installation, the blog is only reachable on the local network. To access it from outside, first set up DDNS. Then configure port forwarding. After that, change the two URL fields in the WordPress admin settings.

WordPress URL settings

At that point, http://yourdomain.com:666 should open the blog from outside.

That could be the end of the setup, but a port number after the domain looks awkward—even if it is 666. So the next step is to remove the port.

In Web Station, enable Name-based hosting and enter your domain as the hostname. Other settings are similar to the earlier virtual host.

Then in the WordPress admin, change both addresses to https://yourdomain.com. Do not miss the s in https.

Set up port forwarding for HTTPS.

Port forwarding for HTTPS

After that, https://yourdomain.com should open the blog.

A quick explanation: HTTP uses port 80 by default, and HTTPS uses port 443. Normally the port is hidden because it is the default. In mainland China, port 80 is generally blocked for home connections, so a domain without a port number has to use 443.

At this stage the browser will show a security warning.

Browser certificate warning

It can be ignored, but it looks bad. The fix is to deploy a free certificate, for example one applied for through Aliyun, on the Synology. After that the warning disappears, and Chrome shows a green lock.

There is still a drawback: on a device’s first visit, the full URL must be typed, including https://. Leaving off https:// will not work. In some ways that is less convenient than yourdomain.com:666.

Try a shorter address with domain forwarding

To get a shorter address, use another domain as a forwarder. You need a separate domain for this. In the forwarding service, configure it to forward to https://yourdomain.com, entering the full https:// part. Then change the DNS servers at your registrar, such as Aliyun, and wait for it to take effect. It is often quick. After that, entering the short domain redirects to the real blog address, so you do not have to type https://www. and the rest every time.

This part can be confusing, so here is the reasoning. The blog is hosted on a home Synology at an address like https://yourdomain.com. If you enter www.yourdomain.com or yourdomain.com, the browser defaults to http://www.yourdomain.com, without the s. Because port 80 is blocked in mainland China, that HTTP address cannot be reached. Unblocking port 80 would require ICP filing, and ICP filing generally requires buying a mainland host. That defeats the point of hosting on a Synology at home, which was partly about using what I already had and avoiding ongoing hosting fees.

Domain forwarding gets around the port 80 problem by using another domain. You might ask why the same domain cannot forward to itself. I thought about that too: point yourdomain.com to https://www.yourdomain.com/. But the domain is already resolving to a server for Synology DDNS. Some DNS providers require ICP filing before forwarding can be configured, and ICP filing again means buying space in mainland China. Adding forwarding records can also create DNS confusion. In practice, the site often failed to load, and pinging the domain returned a different IP address instead of the real blog IP. I do not recommend that approach.

Another idea is to use the same DNS provider for both resolution and forwarding. The conditions are: the provider should be outside mainland China, because domestic providers require ICP filing for forwarding, and it should support binding to Synology or Asus DDNS, for example. But a foreign DDNS provider can be blocked, and changing DNS providers later is a hassle.

Hosting a blog on a home Synology has obvious advantages: it is free, there is no yearly cloud host bill, storage can be expanded as needed, and traffic is not a major concern for a small personal blog. The disadvantages are just as clear. Without buying a mainland host, port 80 is unavailable, so a short domain is hard to use. And putting the Synology on the public internet exposes it to attacks. A NAS often stores important family or company data, so this setup is best for experimentation and hobby use.

Later I bought a VPS for Shadowsocks and had spare capacity, so I planned to move the blog there. That would solve both the port 80 problem and the security concern of exposing the NAS.