How to Host a WordPress Website on a Synology NAS!

Today we are going to look at how to host a WordPress website on a Synology NAS.

A lot of people would like to host a website, but the monthly costs associated with web hosting isn’t always ideal. While it’s a good idea to scale your website to match the daily traffic it receives, it’s sometimes easier to host the website out of your house in the beginning. This avoids monthly charges and allows you to run the site on a device that most people have running 24/7. To be clear, Synology NAS devices don’t have huge amounts of processing power, so it’s not the best idea to host a site with a lot of traffic on a Synology NAS. In future tutorials, we will look at how to use Cloudflare which can drastically reduce the traffic demands on your local NAS, speed up performance, and increase security.

As a fun fact, this site started by being hosted on a Synology NAS. As it grew, I scaled it up to match the demand and it’s now hosted in the cloud.

1. WordPress Synology NAS Package Install Instructions

1. Purchase a domain name if you don’t already have one, as we will be using it in future steps. Namecheap is my favorite provider and the one that I personally use.

2. Open Synology’s Package Center and install the WordPress package.

wordpress synology nas

2. You will be informed that WordPress will automatically install a few different packages. Select Yes. The packages will now download and install.

wordpress synology nas

3. Create a password for the MariaDB package that’s installed. After the password has been defined, select Apply to install the package.

wordpress synology nas

3. Create a password for the MariaDB package that’s installed. After the password has been defined, select Apply to install the package.

wordpress synology nas

5. WordPress will automatically configure a database user. Enter a password that will be used for the wordpress_user.

wordpress synology nas

6. Select Apply to install the WordPress package.

wordpress synology nas

7. The WordPress package is now installed!

2. Creating a DNS Record

This part isn’t difficult, but we have to do it for a somewhat tricky reason. When you install WordPress, it will automatically install using the hostname or IP address you’re currently accessing the website with. Since opening the website will use the IP address of your Synology NAS, we need to create a DNS record or a host record on your local system before installing WordPress. Either will work, we just need to ensure that we’re accessing our WordPress site using the domain name we will be using in later steps.

For example, my site’s name will be dev.wundertech.net, so I will create a host or DNS record for dev.wundertech.net to point to the local IP address of my Synology NAS. This is only temporary, and we will remove this in a later step.

Hosts File

If you’re not using a DNS Server, follow the instructions below to modify your hosts file.

Windows 10 Instructions

Mac OSX Instructions

Ubuntu Instructions

DNS Record

Creating a DNS record will be different depending on the DNS server that you have configured. I use Pi-Hole, so I will create a Local DNS Record for my dev.wundertech.net domain and point it to my Synology NAS’s IP address.

wp13

3. Installing WordPress – Synology NAS

1. Select Open to access WordPress.

wordpress synology nas2. You will be brought to the IP address of your Synology NAS in the URL window. Change the IP address to be the domain name we created in our last step.

wp8.5

3. Select your language and press Continue.

wordpress synology nas

4. Create a Site Title, Username, Password, then enter your email address and search engine visibility. When everything has been entered, select Install WordPress.

wordpress synology nas

5. When it’s finished installing, you will be able to Log In using the password you created.

wordpress synology nas

6. WordPress is now installed!

4. Virtual Host Creation

The WordPress package is now installed, a DNS record has been created, and we will now update our virtual host.

1. Install the Web Station package from Synology’s Package Center.

2. Open the Web Station package and select Virtual Host. Then select Create.

wp14

3. Enter the hostname, select the web/wordpress document root, and select Apache HTTP Server 2.2 and Default Profile for PHP. Enable HSTS/HTTP/2 if you’d like. Select OK.

WP2

4. If you receive a message asking if you’d like to automatically update permissions, select Yes.

wp16

5. The final setting that we need to change allows PHP to access MySQL. Select PHP Settings and on the default profile, select Edit.

wp17

6. Select the checkbox next to mysqli and select OK.

wp18

5. File Changes

Technically, you will be able to get to WordPress now, but if you try and access any specific posts, you will receive an error. The reason is that our Site Address has /wordpress in the URL. We can quickly change this from the WordPress admin settings.

1. Navigate to your domain and add /wp-admin to the end.

http://[DOMAIN_NAME]/wp-admin

2. Select Settings, then General. Remove /wordpress from the end of your URL and save.

wp20

6. Use a Good Caching Plugin

When you’re using something like a Synology NAS as your WordPress server, large amounts of traffic can bog it down as the processor isn’t as cutting age as we’d like. For this reason, using a high-quality cache plugin is integral. For over a year, I wasted my time with “free” caching plugins because I truly didn’t think that the premium plugins were worth the money. I was completely wrong. When I say that I tried to increase the speed of my website for 50+ hours with free plugins, I am not lying. I implemented WP Rocket in about 5 minutes and get better performance than ALL of my previous attempts.

WP Rocket is incredibly easy to use and it WORKS. If you care about SEO, the speed of your site is now a more important ranking factor than it was in years past. I don’t recommend that many services, but if you’re serious about website performance (which you should be) and limiting the impact on your NAS’s processor, WP Rocket is the answer.

I don’t have a tutorial for WP Rocket because it’s so easy to use, but if you would like one, let me know in the comments and I will create one.

7. Website Exposing & Setting up an SSL Certificate

The website will now be set up and configured. Keep in mind, this is a blank website so you’ll probably want to go ahead and customize it before you expose the website to the outside internet. However, at this point, you’re ready to expose the website.

It’s very important to note that you need to have your purchased domain name ready at this point with a DNS record created. I will not be going through this process as there are tons of different registrars where you can purchase domain names, but ensure that you created a CNAME DNS record pointing to your DDNS hostname or an A record pointing to your static external IP address.

Slide1

1. Ensure that you port forward ports 80 and 443 on your router to the IP Address of your Synology NAS. Make sure you create two allow firewall rules for ports 80 and 443. If you aren’t using Synology’s Firewall, I highly suggest you set it up before opening ports 80 and 443. I created a tutorial on how you can set up Synology’s Firewall if you’re interested in learning how to use it.

wp21

2. After the firewall rules have been created and you’ve port forwarded 80/443, open the Control Panel, select Security, then Certificate.

3. Select Add, then Add a new certificate, and Get a certificate from Let’s Encrypt.

wp22

4. In the Domain Name section, type your domain name and then select Apply. It will take a few minutes to validate.

wp23

5. The final step is to select Configure and select the correct certificate next to your domain name.

WP

6. Your website is now configured with an SSL certificate and is ready for external traffic!

8. Conclusion – WordPress Synology NAS

This tutorial was meant to guide you through the entire process of setting up and configuring a WordPress website on a Synology NAS. In future tutorials, we will look at utilizing Cloudflare to use some of the free benefits that they provide.

As always, if you have any questions, please leave them in the comments. Thank you for reading the tutorial!

Please share if this helped you!

This Post Has 61 Comments

  1. Emilio

    Yes, I have tried the virtual host with basic static web pages and it works without any problem.

    1. WunderTech

      I am unfortunately at a loss at this point. Without being able to tinker with it, it’s hard to say what can and can’t work and I apologize. I would say that you need to tinker with the location or the permissions since everything is working without the virtual host. I just feel bad having you try random stuff that I’d normally try in my troubleshooting steps, so I apologize 🙁

      1. Cecilio

        Hi, I am having a similar problem to Emilio. I am describing here my problem in a simple way to see if you or somebody else can reproduce my error and can find a solution.

        I have installed:
        DSM 6.2.4-25556
        Apache2.2
        php7.3
        MariaDB10
        Wordpress 5.5.3-0158

        Just to simplify more the problem I did the following test.

        If in my navigator I search for ‘http://ip.address.synology/wordpress’ everything works fine. And when entering in the admin area ‘http://ip.address.synology/wordpress/wp-admin’ I see that the WordPress Address (URL) and Site Address (URL) are both ‘http://ip.address.synology/wordpress’.

        Then in WorkStation I create a Virtual Host port based:
        HTTP: 81
        Document root: web/wordpress
        HTTP back-end server: Apache 2.2
        PHP: PHP7.3

        And in PHP Settings I only have the Default Profile PHP7.3 where I ticked the MySQL box.

        However, if now I search in my navigator ‘http://ip.address.synology:81’ I get the infamous ‘Error establishing a database connection’.

        This problem appears only with WordPress since if I create a different virtual host where the root folder points to web/webpage1 (containing a simple index.html), I am able to see the webpage. I gave all the permissions to my user (I am admin) in the web folder and all its content, so webpage1 and wordpress folders should have same permissions.

        I am quite new in this world and I am not able to see if I am doing something wrong. Could you confirm that my logic is correct? If you could try to reproduce my error and see if this also happens for you that would be awesome.

        1. WunderTech

          By any chance, when you installed WordPress, did you install it by using the local DNS record and hostname (meaning you navigated to it using the hostname that you wanted to use)? That step is done so that WordPress installs and the site addresses are properly listed. It’s not a huge deal if you didn’t, but you will have to look up how to change them, and then assuming you have it mapped either by local DNS record of A/CNAME record on your registrar, I would assume that it should work.

          I hope this helps!

  2. Cecilio

    Hi, I finally found the solution.

    My setup is basically the same as you described:

    Install WordPress from package center and when you open it, replace in the URL the ip.address.synology by mydomain.com and finalise the setup procedure. (This is done under the URL mydomain.com/wordpress/wp-admin…).
    Then set up the virtual host in web station:
    Hostname: mydomain.com
    root: web/wordpress
    and in php-settings select mysqli.

    If now I navigate to mydomain.com I would get the “Error establishing database connection”.

    So the new thing I had to do was to modify /web/wordpress/wp-config.php with the following:

    1. Replace define( ‘DB_HOST’, ‘localhost’ ) by define( ‘DB_HOST’, ‘localhost:/run/mysqld/mysqld10.sock’ ). This is particular of MariaDB 10.

    2. Replace
    define(‘WP_SITEURL’, $pageURL.$alias);
    define(‘WP_HOME’, $pageURL.$alias);

    by

    define(‘WP_SITEURL’, ‘http://mydomain.com’);
    define(‘WP_HOME’, ‘http://mydomain.com’);

    So now when going to mydomain.com I correctly get the webpage and with mydomain.com/wp-admin I access the backend and here I can check that now both WordPress Address (URL) and Site Address (URL) point to http://mydomain.com

    This could probably fix the issue that Emilio was also facing.

    1. WunderTech

      This is awesome, thanks so much for sharing! Very happy to hear you were able to get it working!

    2. Normand

      Thanks a lot Cecilio ! What was suppose to take minutes to configure finally took me a day but now WordPress is working from both my LAN and WEB.

    3. Dennis Yildirim

      @Cecilio !!!!!!!!

      Mate thanks heaps! I spend more than 3 days just to be able to figure out this problem, and went all over the web, checked every guide that I could fin in the first 20 pages of google searches, nothing worked.

      Long story short for others: If you are encountering that database connection error, it is simply because of Maria DB10 using that string you pasted above. I did not even needed to change the rest. As soon as I pressed save, my domain started working.

      Youre a legend, hope you have a good one !

    4. Martin

      Thank you so much for this, Cecilio! That was the missing brick in the wall. Interesting that with some installations this is required and with others not.
      One thing that also cost me some time and research: The fields for “WordPress-Adress (URL)” and “Website-Adress (URL)” were grayed out in WordPress settings. These have to be edited in wp-config.php directly (as Cecilio described).

    5. Stefan

      Just wanted to tack on the thanks here!! Was going nutty!

  3. Alexandru Tomescu

    Thanks Cecilio !

  4. Nick

    Hello,

    Trying to install wordpress on my NAS but I’m stuck in the step where u need to create a virtual host. It seems if u install the package the NAS automatically creates a portal but with less options. When I want to create a virtual host like u do I can’t select \web_packages\wordpress and that’s the place where the NAS installs wordpress. How can I install it in \web\wordpress or is there another solution for this?

    Thanks for everything.

    1. WunderTech

      When you say you can’t see the location, are you signed in with an admin account that has permission to everything? It should allow you to select that location – also, are you on DSM 6 or 7?

  5. vlad

    Hi, i got installed wordpress everything the whole setup is done in DSM 7. the only problem i am facing now is to change the url from example.com/wordpress to fully another domain test.com i created here virtual host with the domain is working but it have access only to the home folder and not to the subsites i guess its because in wordpress is still under general settings the domain example.com/wordpress but its greyed out and i am unable to change that to the test.com url
    Do you have please may any idea how to change the url?

    thanks for helping here

    1. WunderTech

      What URL exists inside of the WordPress website? Does it have the “/wordpress”?

  6. noah

    So this is my first time working through WordPress or the Synology NAS, I’ve designed and built my website already but the domain is still the IP address, is there a way I can change the name now, even though I didn’t create a DNS record before installing WordPress?

    1. WunderTech

      You can, but it’s a little bit of a pain. I would start by changing the IP address inside of WordPress to be the correct URL, but you might have to play around with a few packages to replace some of the settings where the local IP address is stored. Best case scenario, the replacement of the URL works. Worst case, you might have to play around with it, but it’s 100% doable.

  7. James

    I am getting stuck on replacing “ipaddress/wordpress/wp-admin/install.php” with “mydomain.com/wordpress/wp-admin/install.php”.

    I am getting the following:

    This site can’t be reached Check if there is a typo in mydomain.com.
    If spelling is correct, try running Windows Network Diagnostics.
    DNS_PROBE_FINISHED_NXDOMAIN

    I followed the other video for setting up Pi-hole(v5.1.1) and was able to add to the “local DNS Records”.

    1. WunderTech

      When you installed WordPress, did you have the DNS record setup at that time? Or are you trying to go back and change the IP address to be the domain name?

      1. James

        Thanks for the quick reply! I did not install wordpress yet because I wanted to install it on “mydomain.com” instead of the IP address as you mentioned in the video.

        So I followed the instructions in this video. When the dns pi-hole piece came up I paused it and went to “https://www.wundertech.net/how-to-setup-pi-hole-on-a-synology-nas-two-methods/”. I then followed those steps and once completed I went back to “How to Host a WordPress Website on a Synology NAS!” video. I was able to add the local dns record for “mydomain.com” and “synology IP address”.

        I tried a couple times uninstalling/reinstalling everything and now I get error ” Error 404: The page you are looking for cannot be found.” when i change “synology-ipadresss/wordpress/wp-admin/install.php” to “mydomain.com/wordpress/wp-admin/install.php”

        1. WunderTech

          No problem! Yes, changing it after the fact is a little tough since it’s buried in the installation at that point. So if we take a step back, now that you have the DNS server set up, when you try and reinstall WordPress, will it install with your domain name?

Comments are closed.