Before We Begin
Please read this before you indulge into my guide to multi-host websites from your Synology NAS.
The guide is a reference to help you install and configure the essentials to support multi-hosting including SSL certificates. Your Synology NAS should be compatible if you are able to download the WordPress application from the Synology DSM (You will not be required to download it from Synology Package Centre from the DSM. However, it is a compatibility reference to allow you to use my guide).
There are several components in this guide which are required to sucessfully complete these steps.
IF YOU ARE UNCERTAIN, OR, UNABLE TO SUCCESSFULLY COMPLETE MY STEPS. PLEASE CONTACT ME, USING THE CONTACT SECTION ON THIS WEBSITES HOME PAGE.
This guide is suited for users with Static Public IP’s (Most residential internet routers do not support Static Public IP, please refer to your service provider for more details). However, it can be achieved with a Dynamic Public IP’s, it just needs DDNS set up in the “Control Panel” of the DSM on your Synology NAS, and to register a DDNS domain name with a provider such as noip.com.
For the sake of these steps, I am going to use expressions such as “example.com” as a reference to your domain name.
* Compatible Synology NAS
* ISP Router with Static IP capability
* Registered Domain Name with your registrar
1. Go to your domain name registrar and make two changes: point your A record for example.com to the public IP address of your gateway (router). Then make a CNAME record pointing “www” to your domain name (example.com).
2. Go to your router settings under Port Forward, and port forward port 80, 443, 20-21, 5000 and 5001. Each port needs to be set as TCP (Transmission Control Protocol for best quality data transfer, UDP may cause errors in data)
3. On your Synology DSM, install and run the following applications from the application centre;
- PhP 7.4
- Apache 2.4
4. In MariaDB make a root password, then in phpMyAdmin log in with those credentials (username: root, password: yourpassword) and make a new user, fill in username, password and assign that user all Global Privileges. Then make a new empty database and call it “Example”.
5. Go to “File Station” on your Synology and make a subfolder in the “Web” folder and name it “Example”. Make sure you set privileges for “HTTP” and the account you are logged into the DSM to administrate the folder. To do this, right click on the “Example” folder and select “Properties”. Then click the tab “Permissions” and select “Create”. Make sure the HTTP user you set is only allowed to Read and Write all set permissions. Then make the user for the logged in account, and set the permissions to Administration, Read and Write to all selected. When you are done click “Ok”, then “Ok” again.
6. Go to the Web Station in the Synology, then, go to “General Settings” and select “HTTP back-end server” and select Apache HTTP Server 2.3, and “PHP” select PHP 7.4. Next go to “PHP Settings” tab, double click on PHP 7.4, then select “Enable PHP cache” and tick all Extensions that will apply to your website. Next, go to “Virtual Host” and create two new entries, one for “example.com”, another for “www.example.com”, Select ports” 80/443”, then in “Document root” browse the location under web/Example (This is where your domain name example.com will be directed to). Make sure you select “HTTP back-end server” as Apache HTTP Server 2.4, and “PHP” select PHP 7.4.
7. Next, you will need to assign a new SSL Certificate to support https secure tunneling for your website and other ports. On your Synology, go to “Control Panel”, then “Security”, then select the “Certificate” tab. Click “Add”. You will then see a dialogue box to set up a certificate. Click “Add a new certificate” and next, give your domain name a description (e.g. www.example.com), click “get a certificate from Let’s Encrypt” then click next. Under “domain name” put example.com, then click “Apply”. If successful you should see your new certificate in the Certificate tab in the Control Panel. You will need to then highlight your new certificate “www.example.com” and click “Configure”. You will find a drop-down under the name “www.example.com”, then select your certificate names “www.example.com”. Then click “Ok”. Once you have done this, repeat this step to make a new certificate for “example.com”, so that it will still be recognized if example.com URL is entered in the address bar instead of “www.example.com”.
8. Download a copy of WordPress from wordpress.org and unzip it from your file directory that it gets downloaded to. Next, within the unzipped folder, drag all the contents of the unzipped file into the /web/Example folder on the File Station.
9. Open the “Example” folder and find the “wp-config-example.php” file. Make the following changes:
- DB_NAME ‘Example’
- DB_USER ‘phpMyAdmin username’
- DB_PASSWORD ‘ phpMyAdmin password’
- DB_HOST you will need to replace with this: define( ‘DB_HOST’, ‘localhost:/run/mysqld/mysqld10.sock’ );
- Make sure you change the $table_prefix ‘wp_’, and give it a code for the database you created earlier, it needs to be unique for example, $table_prefix ‘example_’. Then save this file as “wp-config.php”.
10. In your new “wp-config.php” file, add the following entries, before the “that’s all, stop editing” message:
- define( ‘WP_DEBUG’, false );
- define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
- define( ‘FS_METHOD’, ‘direct’ );
- define( ‘FORCE_SSL_ADMIN’, true );
- define( ‘WP_ALLOW_REPAIR’, true );
- /* That’s all, stop editing! Happy publishing. */
11. You will then need to visit https://api.wordpress.org/secret-key/1.1/salt/ and highlight all the content by selecting the text and Ctrl + A and copy and replace the section in the “wp-config.php” file:
- define( ‘AUTH_KEY’, ‘put your unique phrase here’ );
- define( ‘SECURE_AUTH_KEY’, ‘put your unique phrase here’ );
- define( ‘LOGGED_IN_KEY’, ‘put your unique phrase here’ );
- define( ‘NONCE_KEY’, ‘put your unique phrase here’ );
- define( ‘AUTH_SALT’, ‘put your unique phrase here’ );
- define( ‘SECURE_AUTH_SALT’, ‘put your unique phrase here’ );
- define( ‘LOGGED_IN_SALT’, ‘put your unique phrase here’ );
- define( ‘NONCE_SALT’, ‘put your unique phrase here’ );
12. If the domain name you bought from the registrar has propagated, type “example.com /wp-admin/install.php” in your browser and follow the setup instructions. When you get the Welcome screen, set your website title, email address, username and password for logging in to “example.com/wp-admin”.
13. After you log in, go to “Settings”, then “General” tab and scroll to the bottom and press “Save” to update the “.htaccess” file. After this you will need to go to “Settings”, then “Permalinks”, under “Common Settings”, select “Post Name” permalink to give the website URL elegancy.
That’s it! You can now log into the backend of your site at example.com/wp-admin.
Repeat these steps for each WordPress hosted website example2.com, example3.com so on and so forth.