Set up a Website on your Synology Server DSM6
Posted: Wed Dec 06, 2017 12:24 pm
There is a newer version available for DSM 7.
Before setting up your website, configure the router to forward the correct ports to your Synology. You can do this manually or use the Synology EZ Internet feature. (This feature may not be compatible with all routers) Log in to your Synology and select the main menu which is the four boxes at the top left of your DSM home page then select EZ Internet.
EZ Internet first displays a list of functions to be performed during execution, then select next.
On network setup page, select the type of connection for your Synology. For most users this will be a shared router. Select this option if everyone on your LAN shares the same ISP connection. If you have a dedicated line or direct connection you can select that option and select next.
On the internet connect page enter the local connection address for your Synology. Enter the local IP address and select next.
The wizard will detect your router information and display if it is compatible and passed the test. If your router passed, select next. If it did not pass select cancel and manually configure the router to forward ports 80 and 443 to the Synology local IP address.
The next screen is informational and displays the router found, select next.
The built in applications page shows all the applications and the ports to forward. To run your website enable Web Station, Photo Station and Web Mail for ports 80 and 443. You can select ports for additional applications you might use. For example, if you plan to use Synology apps to remotely connect to DSM check the two ports shown at the red arrows for Management. Another handy option is to create multiple sets of rules. This makes it easy to enable or disable the additional features without affecting access to your website.
The DDNS Wizard page allows you to setup a host name if you registered with Synology. A Synology host name will end with an extension registered to Synology. If you plan on registering a unique host name for your domain, select the Skip this step radio button, then select next.
The confirm settings page show the actions that will be performed if you continue. Check each entry and if something is incorrect use the back button to make corrections.
The Apply setting page writes the selections to the router when you select finish. Your router setup is now complete and will forward the correct ports for internet access.
If your router is not compatible with EZ Internet, consult your router instructions and manually enable port forwarding for port 80 (HTTP) and port 443 (HTTPS) to your Synology. If you want to access DSM over the internet you will need to forward the ports you specified for DSM. The default ports are 5000 for HTTP and 5001 for HTTPS.
Creating a Website
Creating a website requires Synology's Web Station available from the package center. Synology has a great feature called QuickConnect. You can access the Synology over the internet using quick connect, if you registered the device and have an account setup with Synology. However this feature connects to Synology DSM and not a web page. This is fine if you are only using DSM services like File, Photo, Surveillance or Video Stations but it does not allow access to pages on a website. To download Web Station log in to DSM and select Package Center from the menu. Select all then scroll down to Web Station and select install. Most programs use php and many require a database. So while you are in the package center, install MariaDB and php. Note if you install Synology WordPress the php and MariaDB programs will install automatically.
In order to set up your first web page register a domain name so users can find and access your website. Online searches will list many vendors offering domain names, SSL certificates and hosting. You do not need a host since you have a Synology server but you do need a domain name. I prefer NO-IP.com because they offer excellent services and support but there are other companies like NameCheap.com, Hover.com, Gandi.net, and Name.com that can register your domain name and offer additional services. If you have a dynamic IP address, make sure the provider offers DDNS service. Additional useful services are DNS Host (A), DNS Host (Round Robin), DNS Alias (CNAME), Port 80 redirect, Web Redirect and WildCards. These features are useful for many things including Google Maps. Some offer mail services for your domain name as well.
So before you order a domain name, determine if you have on a static or dynamic IP address. Most business IP addresses are static while residential IP addresses are usually dynamic. A static IP address does not require DDNS because the address is always the same and is registered with the domain name. Dynamic IP addresses are not registered with a domain name and require a DDNS provider. Dynamic addresses use DDNS or Dynamic Domain Name System. DDNS providers update the DNS servers when an IP address changes. A Dynamic IP address will usually change if you reboot the modem or experience a power interruption. You can get information about your connection type from your ISP (Internet Service Provider). The DDNS function on a Synology connects to your DDNS provider and either confirms or updates your IP address so DNS servers can find your website when the IP address changes.
Add DDNS Service
Once you have a domain name enter the information in your Synology to setup the DDNS service. So log in to DSM and open the control panel.
Select External Access from the connectivity group. The DDNS tab is where you enter information about your DDNS.
Select the Add button and the DDNS configuration windows appears.
From the pull down menu select your DDNS provider.
If you selected a DDNS provider that is not on the list you can use the customize feature to add your provider. Select cancel on the DDNS window to return to the DDNS options and then select Customize.
In the service provider window type in the name for your provider. This is the name that will appear in the pulldown list of DDNS providers.
In the Query URL window enter the query string for your DDNS provider. If you do not know the query string contact your provider. The string will be similar to:
Code: Select all
http://dynupdate.DDNS_Provider/nic/update?hostname=__HOSTNAME__&myip=__MYIP
Return to the DDNS tab and select add. Notice when you select the pulldown, the additional providers you added are on the list. The additional providers will have an * preceeding the name you entered. You can also add the same provider multiple times if you want to create additional websites. Notice I added two additional NOIP entries. When you add the same DDNS provider more than once, you need a unique name. You cannot enter the exact same name twice so add something to the end of the provider name to make it unique.
Select your provider and enter your information on the set up screen.
Hostname: This is the domain name you selected. This much match the domain name you registered. If you registered both www and non-www names enter the non-www host name here. Your DDNS service may allow you to configure group IP address updates for additional www and FTP sites. If they don’t you can update the DDNS manually or add multiple DDNS entries for the www and FTP hosts by repeating these steps and adding www. or ftp. before the domain name.
Username/Email: This is the login user name for your DDNS provider.
Password/Key: This is the password or key you use to login to your DDNS provider.
When finished select the OK button to save your settings.
Enable WebSite Access and Set Up Firewall Rules
Now you must enable access to your site. Synology has a firewall to permit or deny access. To verify your site is accessible, go to control panel and select Security.
Select FIreWall from the tab at the top of the page. It is a good idea to enable the firewall to protect your DSM. Enabling notifications allows your Synology to tell you when something is not enabled that would prevent the package from working correctly.
Select Edit Rules from the center right portion of the page to create rules for your website.
Your rules page may be blank. To create a rule select create at the top of the page.
The firewall rules page has a few options. You can create rules to access or deny ports, applications, source IPs or regions. The radio buttons at the bottom of the page determine what happens if no rules are matched. If you set up deny rules for security, make sure you are not denying yourself access to your own system.
Choose the Select radio button for built-in applications and then click the Select button.
You can scroll to choose which applications you want to enable though the firewall. Make sure ports 80 and 443 (Web Station, Photo Station) are enabled which allows internet access. The DSM ports must be checked to allow the Synology assistant and remote connections to connect to DSM (Disk Station Manager).
When finished select OK and the parent screen appears. Notice the source IP on the last line, Enable local access on all ports so you do not lock yourself out of your own Synology device. The common LAN (Local Area Network) address range is 192.168.1.1 - 192.168.2.255. If you are using DHCP (Dynamic Host Configuration Protocol) and specify a specific IP address instead of a range, the router can assign a different IP address to your PC when you restart or reboot, locking you out of your device. Once you become more familiar with your device and port access, you can change these settings later if needed.
At this point you should be able to access your site from the internet. When you connect the following page appears which is seen by every Synology user after they install Web Station.
This page appears because that is the only web page in the web folder. This message will remain until you replace the page or point to another folder containing a program or html page. You can install a program in the web folder and if you're only going to run that one program you're done. If you want to run more than one website or install Synology WordPress, install the programs in separate folders inside the web folder. Since the programs do not reside in the root folder, traffic must be directed to the correct folder so WordPress, TNG, phpBB or whatever program you want to run will load. Keep in mind if your IP address points to the web folder, anything you place in that folder can be accessed from the internet, unless you specifically deny access. There are a couple of ways to direct browsers to program folders. I prefer using virtual hosts because they are easy to set up and allow you to run multiple websites using one IP address. Additionally Virtual Hosts prevent access to other folders located in the web folder.
Setup a Virtual Host
In this case we will use WordPress for the example since the Synology version of WordPress resides in a folder inside the web folder. When you install the Synology version of WordPress, MariaDB, Apache and php are installed as well. WordPress will not load when first installed because your website IP address points to your web or root folder. To access any program installed in a sub-folder such as WordPress, set up a Virtual Host. Another advantage of Virtual Hosts is you can use them to direct non-www and www domain names to the desired folders by setting up two Virtual hosts.
Synology makes adding a Virtual Host very easy. Select Web Station from the main menu. Select the general settings tab and select the default services. You can use nginx or Apache for the backend server. I suggest Apache unless you are going to run an nginx specific program. You also need to select the php version that was installed. Make sure you select apply before changing pages so your selections are saved.
Setup PHP for your Virtual Host
If you install the Synology version of WordPress, Synology sets up the PHP extensions automatically. If you are planning to use other software or install the WordPress.org version then you will need to enable the PHP extensions manually.
Login to DSM and go to web station.
Select General Settings
Select HTTP back-end server:
From the pull down select the Apache version installed either 2.4 or 2.2
Select PHP settings
From the pull down select the php version installed either 7.0 or 5.6
Then select Apply
Select PHP settings
From the pull down select PHP version 5.6 (if installed)
Make sure the Enable PHP cache is checked. If you enable display_errors, users will be able see php errors. You should only enable this feature when trouble shooting. Alternately you can enable php eror logs.
Scroll down the extensions and check all the boxes except libsodium and ssh2 and select Apply

From the pull down select PHP version 7.0 (if installed)
Make sure the Enable PHP cache is checked. If you enable display_errors, users will be able see php errors. You should only enable this feature when trouble shooting. Alternately you can enable php eror logs.
Scroll down the extensions and check all the boxes except ssh2 and select Apply

WordPress does not require every extension but software you install at a later date might require options not used by WordPress.
Create and Configure Virtual Host
Then select the Virtual Host button and select create.
Enter your domain name in lower case letters and do not use any spaces or underscores. (It is best to avoid special characters like hyphens) Leave the default ports (80 and 443) checked.
Select Browse and then select the folder with the program or page you want to display when someone enters your website. Select the Apache Backend Server and the current version of php installed. (NOTE: If you select NGINX WordPress permalinks will not function correctly unless you modify the conf files)
Select OK to create the VIrtual Host. You domain name will point to the folder you just created.
The second method is creating a php or html index file
If you don't want to use a virtual host, you can create a file in the root folder that loads WordPress. Browsers load index.html files first so you must delete or rename the original Synology index.html to something like syno-index.html. If you don't make this change, the new index.php file won't load. After you delete or rename the file use a UTF-8 editor like Komodo IDE or NotePad++ to create the index.php file and place the following code in the file. This assumes you are using WordPress so the folder is named wordpress. If the folder name is different you will need to change it. Note: if you install Synology WordPress, this file is created automatically in the web folder.
Code: Select all
<?php
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
Save this file in the web folder. When someone accesses your site this file will load WordPress. If you have WordPress installed in a wordpress folder, you can download an index file by selecting the link below then save it in your web folder:
If you use the Apache backend, each program folder should contain an .htaccess file. This file sets the rewrite base for the program you install. If you install WordPress it will create the .htaccess when it installs. Some programs do not create this file so you may have to create one yourself. Here is an example of the minimum requirement for the file:
Code: Select all
RewriteEngine On
RewriteBase /Folder_Name/
To create the file use a plain text editor such as Komodo IDE or NotePad++. DO NOT use a word processing program. If you do not have an .htaccess file in the folder, the folder name may get appended to the URL causing your program to malfunction.
If you have some experience with html you can download the My Front Page file and create your own landing page. It contains an index.html and a css file. Extract the ZIP file contents to the web folder. You will need to change/add the text you want displayed as well as links to folders containing your programs or pages. To add a link in the index file, change:
Code: Select all
<a href="#">
Code: Select all
<a href="/folder_name/">
Code: Select all
<a href="http://example.com/">
File moved to updated post for DSM7