Running a WordPress website on your NAS includes maintenance. In the fourth and last part of this series you learn about backup, installing another WordPress instance, and how to suspend, reset or uninstall WordPress. At the end we touch the benefit of a local DNS server for your WordPress site.
Install WordPress on Synology NAS (part 4)
This is part 4 in a series of 4 about hosting WordPress on Synology NAS. The four parts each cover a different area of the topic.
- Part 1 – introduction to WordPress on your NAS
highlight the different scenarios and necessary preparations
- Part 2 – install WordPress from Synology
highlights the installation steps of this setup
- Part 3 – install WordPress from WordPress.org
highlights the installation steps of this setup
- Part 4 – WordPress maintenance (this post)
backup, second instance, suspend, reset and uninstall, internal DNS setup
- Install WordPress on Synology NAS (part 4)
- WordPress Backups
- Install a second WordPress instance
- Suspend WordPress
- Reset WordPress
- Uninstall WordPress
- Stop phpMyAdmin
- DNS Server setup
When you install WordPress on Synology, you should take a moment to consider your WordPress backup. You have two options, the Server-side backup and the Inside-WordPress backup, and you can do either or both.
Since you host your website, you can make a backup from the files and folders and the database that comprise your website.
The advantage of a server-side backup is that you can restore the website when it is broken, inaccessible, or removed. You can use Hyper Backup for this purpose.
The advantage of Hyper Backup is that it backs up your files and folders and application data from Web Station and Maria DB.
Ensure that you add the /web and /web_packages shared folders plus the MariaDB 10 and Web Station applications to your backup task.
Please note that Hyper Backup suspends the operation of the Maria DB application during the backup. As a result, your website is temporarily unavailable.
For reference, look up my Hyper Backup datasheet.
With Hyper Backup, you can selectively restore a file or folder but only restore the entire Maria DB database. That may not be an issue if you have only one application that uses this database. Otherwise, other database-driven applications are affected by the restore as well.
Alternative database backup
An alternative for the Hyper Backup database backup is the database export with phpMyAdmin, a MySQL database management tool. phpMyAdmin lets you import databases selectively, and this tool does not temporarily suspend the operation of Maria DB.
For reference, look up my phpMyAdmin datasheet.
There are a few issues to take care of when you restore an entire WordPress website removed from your NAS.
Restore WordPress from Synology
Assume that you have the backup mentioned above but removed the WordPress setup entirely. Just re-install the WordPress package from Package Center, which will install all dependencies, the other applications, and WordPress’s services. This installation includes the root and wordpress_user accounts in the database.
Do not perform the last step, the 5 minutes setup in WordPress. It is not harmful if you do, but it is unnecessary.
Restore the backup, particularly the /web/wordpress folder (DSM 6) or /web_packages/wordpress folder (DSM 7) and the Web Station and MariaDB 10 application data. When the restore process finishes, your website is back again.
Restore WordPress.org setup
For a successful restore, make sure you install dependencies like Apache HTTP Server 2.4 and PHP 7.4. Note that both Web Station and MariaDB 10 recover during a backup restore.
Restore the backup, particularly the /web and /web_packages (DSM 7 only) shared folders and the Web Station and MariaDB 10 application data. When the restore process finishes, your website is back again.
However, there may be a problem accessing the website or logging in when you have an SSL certificate for the site. Check the virtual host configuration in Web Station and the linked certificate in Control Panel > Security > Certificate tab.
To fix this, go to Control Panel > Security > Certificate tab. Click on the Configure button (DSM 6) or Settings button (DSM 7) and re-establish the certificate and service connection. The service represents the virtual host in Web Station.
Now your website should run as before.
In addition to or instead of the server-side backup, you can make backups from within WordPress, the Inside-WordPress backup. You install a plugin in WordPress from your admin pages for this backup, also known as the Dashboard. This backup will only backup that specific website. If you have multiple WordPress instances running, you install a plugin in each website’s admin pages and make a backup.
There are several good backup plugins, and UpdraftPlus is just an example. This is a popular backup plugin, and it let you save both the database and the files. And the plugin is free with some paid options.
You can select which component you like to restore during a restore: database, themes, plugins, uploads, and other parts, and Updraft restores the chosen piece entirely. For example, you restore the database, and the entire database for that website is fixed, but other databases on your NAS are not affected, like with the server-side backup.
The UpdraftPlus backup plugin can save the backup on your NAS in a dedicated folder between your WordPress folders or on a cloud service like Dropbox, OneDrive, or Google Drive. If you save it on your NAS, it would be wise also to do a server-side backup to another destination in case your NAS fails.
An Inside-WordPress backup is excellent for daily backups and in-between maintenance like plugin and WordPress updates.
Install a second WordPress instance
When you install WordPress on Synology, you might want to install multiple instances of WordPress. This way, you create numerous WordPress websites on the same NAS for different domains.
Note that the WordPress from Synology installation, described in part 2, does not allow for a second instance.
Referring to the installation and configuration as outlined in part 3, you skip all package installations and head over to the steps for installation of the WordPress folder. Create another folder in the /web shared folder and copy the WordPress files from the WordPress download to that folder.
Next, continue with the entire configuration process, including setting permissions, creating a new user in the database, installing the SSL certificate, adding a virtual host, and up to the WordPress 5-minute install.
The virtual host will determine which website is called upon based on the domain name. There is no need to configure other ports in either the internet router or your virtual host in Web Station.
As with the first website and the domain name you use, you must configure the domain name for other websites on your NAS accordingly.
You might want to (temporarily) suspend the operation of your WordPress website without affecting the entire setup of the database, files and folders, and all configurations. There are several ways to achieve this, depending on what you want to achieve and which kind of installation you have.
You can stop forwarding ports 80 and 443 on your router to your NAS. Stopping forwarding suspends external access to your website(s), not internal access.
Note that this step affects other websites on your NAS and potentially other services that rely on the same ports, like updating SSL certificates.
Suspend WordPress from Synology
If you have a WordPress website set up with the WordPress package from Package Center, you can stop the service for that package. You can do this from Package Center. Please reference the WordPress datasheet for details.
Stopping the WordPress service affects only the WordPress website, not any other websites you might have, like Joomla or other web-based applications on your NAS.
Suspend WordPress.org installation
A WordPress.org installation is less easy to suspend. You can stop the Apache HTTP Server 2.x or the MariaDB 10 service from Package Center. Please reference their respective datasheets for Apache or MariaDB.
Note that this affects other websites dependent on either of these services.
You have tested a WordPress installation, messed around with it, and would like to start again from scratch. You let the entire underlying infrastructure intact but only refresh what WordPress created.
As with suspending WordPress, I explain how to reset it for the Synology and WordPress.org setup.
Reset WordPress from Synology
At first glance, this is a straightforward process, but there is a catch.
First, uninstall the WordPress package from Package Center. Please reference the WordPress datasheet. Removing the WordPress package also deletes the database for that website. However, it leaves the wordpress_user in the central database.
Next, you install the WordPress package again from Package Center. You fill in the root account password, which you hopefully kept safely. Next, you fill in the password for the wordpress_user, and the connection to the database fails.
The uninstallation of the WordPress package resets the wordpress_user’s password. There are two workarounds to solve this.
- In the WordPress setup, create a new user account by changing the name to something different from the default wordpress_user
- Reset the password for wordpress_user in the database with phpMyAdmin; a daily task for a database administrator, but not for those who opted for ease of installation
- Re-install the MariaDB 10 package and the WordPress package; this removes the entire database including the wordpress_user, making a fresh start.
I think options 1 and 3 are probably the easiest, but it all depends on your skill level.
Reset WordPress.org installation
As you’d expected, resetting the manually installed WordPress.org setup is a manual process. It involves two steps:
- remove the database user and drop the database
- refresh the WordPress folder
There is no preferred order in which you execute both steps.
Remove user and database
Log in to phpMyAdmin. In the left column, select New.
On the main screen at the right, select the User accounts tab. Select the user to remove. In my case, this is wpsd, but your name is probably different.
Under Remove selected user accounts, you enable the option Drop the database that has the same names as the user. Click Go.
You must drop the database separately if the user and the database do not have the same name. Continue in phpMyAdmin.
Select New at the top in the left column. On the main screen at the right, select the Databases tab. Check the database to remove or drop in SQL talk. Click on Drop, just below the list of databases. You get a pop-up (You are about to DESTROY a complete database!) and confirm with OK.
Next, create the database user again with the database described earlier under Create WordPress and user in part 3 of this series.
Refresh the WordPress folder
To refresh the WordPress files, go to the proper folder under the /web folder. For example, in part 3 of this series, I created /web/wpsd, but you can use your name for the subfolder. Remove all files and folders in that folder but leave the folder intact.
Next, download the WordPress zip from the WordPress.org download page, and unzip it on your computer. Next, copy the contents of the wordpress folder from the zip into the /web/wpsd folder (use your subfolder name) as described earlier in Copy WordPress files in part 3.
Add two lines of text to the wp-config-sample.php file described in Change wp-config-sample.php in part 3 of this series.
Continue with a fresh installation of WordPress. Follow the guideline in part 3, WordPress pre-install.
If you like to take things a step further and plan to thoroughly uninstall WordPress on Synology and dependencies, uninstall the packages in the reverse order you installed them. Some packages offer the option to remove their data. When you remove Web Station, consider removing the /web, and /web_packages (DSM 7 only) shared folders. You can use Control Panel > Shared Folder for that task.
Hyper Backup can back up MariaDB 10 and Web Station applications and folders. Remove them from the backup task to prevent Hyper Backup from generating an error message. See the backup configuration with Hyper Backup earlier in this post.
Lastly, remove port forwarding to your NAS from your router. Change the configuration of your DNS domain to reflect the new situation.
A user pointed out that phpMyAdmin is always accessible from the internet. This is not a desirable setup from a security standpoint.
Therefore I suggest pausing phpMyAdmin when the installation and configuration of WordPress are finished. Except for incidental maintenance, you do not need this tool.
Log in to DSM, open Package Center and search for phpMyAdmin. Next, click on the icon of the package. The phpMyAdmin screen opens. Open the drop-down list in the button and select Stop.
DNS Server setup
If you like to access your WordPress website with a domain name, you must configure DNS. You can set up a DNS server on your NAS if you want a shortcut for connecting locally. The overall process is as follows:
- install DNS Server from Package Center
- open DNS Server application and enable forwarding
- in the DNS Server application, create a forward lookup zone for your website domain
- add an A record for your website, using your internal IP address
Now, you have set up the DNS Server. The next task is to ensure your computer uses this DNS Server instead of your router or one on the internet. Go to the network properties of your computer and change the IP address of the DNS Server into the IP address of your NAS that runs the DNS Server. Now only your computer, not other computers, tablets or smartphones, use your DNS Server.
Alternatively, change the DNS Server configuration in the DHCP settings in your internet router, and have it point to your DNS Server.
Thanks for reading
Paul Steunebrink / Storage Alchemist