Set up a Website on your Synology Server

Post Reply
Steve
Posts: 62
Joined: Sun Oct 01, 2017 3:08 pm

Set up a Website on your Synology Server

Post by Steve » Wed Dec 06, 2017 12:24 pm

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.

Image


EZ Internet first displays a list of functions to be performed during execution, then select next.

Image

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.

Image

On the internet connect page enter the local connection address for your Synology. Enter the local IP address and select next.

Image

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.

Image

The next screen is informational and displays the router found, select next.

Image

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.

Image

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.

Image

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.

Image

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.

Image

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.

Image

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.

Image

Select External Access from the connectivity group. The DDNS tab is where you enter information about your DDNS.

Image

Select the Add button and the DDNS configuration windows appears.

Image

From the pull down menu select your DDNS provider.

Image

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.

Image

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
Select save to add your DDNS provider to the list.

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.

Image

Select your provider and enter your information on the set up screen.

Image

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.

Image

Select FIreWall from the tab at the top of the page. It is a good idea to enable the firewall to protext 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.

Image

Your rules page may be blank. To create a rule select create at the top of the page.

Image

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.

Image

Choose the Select radio button for built-in applications and then click the Select button.

Image

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).

Image

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.

Image

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.

Image

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. 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.

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.

Image

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 and Enable display_errors to display PHP error message are checked
Scroll down the extensions and check all the boxes except libsodium and ssh2 and select Apply

Image

From the pull down select PHP version 7.0 (if installed)
Make sure the Enable PHP cache and Enable display_errors to display PHP error message are checked
Scroll down the extensions and check all the boxes except ssh2 and select Apply

Image

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.

Image

Enter your domain name and leave the default ports (80 and 443) checked.

Image

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 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, NotePad++ or WordPad to create the index.php file and place the following code in the file. Note: this assumes the folder is named wordpress. If the folder name is different you will need to change it.

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:

index.zip
(332 Bytes) Downloaded 247 times

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/
"Folder_Name" is the name of the folder were the program is located. So if you want to run two different website programs, you must have two different folders and each folder should contain an .htaccess file with the correct RewriteBase information.

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.


middlecee
Posts: 1
Joined: Fri Jun 01, 2018 3:12 pm

Re: Set up a Website on your Synology Server

Post by middlecee » Fri Jun 01, 2018 3:42 pm

At one time, the word press domain name was working. I typed in the domain name, and it came up. now, it says server can't be found.

it all happened because i changed lan ports. At the back of the nas, it is now in LAN 2. I changed all the information, on net gear router side, reinstalled and installed wordpress, so it can somehow read as the right Lan address. did everything it seems, and it can't come up.

i an taking a wordpress plugins course starting soon, and can't get my site to come up from the browser. it works, it is there, from the local end, when i type in the http:// etc, but not from the www. side of things.

didn't know if i should erase all the old files too from the web folder? to try to just start again from scratch?

there is nothing on the site, which is good. nothing to lose, but i am frustrated why it doesn't work.

been at this for a couple days now. sent in a support ticket. waiting to hear something back to trouble shoot.

i have a static ip, with the right certificate. everything seems to be fine, but i think it has to be with the old files? of old word press? having it with old LAN 1 , from back of the NAS. It changing from LAN 1 to LAN 2 completely messed things up.

Steve
Posts: 62
Joined: Sun Oct 01, 2017 3:08 pm

Re: Set up a Website on your Synology Server

Post by Steve » Fri Jun 01, 2018 9:22 pm

middlecee wrote:
Fri Jun 01, 2018 3:42 pm
At one time, the word press domain name was working. I typed in the domain name, and it came up. now, it says server can't be found.

it all happened because i changed lan ports. At the back of the nas, it is now in LAN 2. I changed all the information, on net gear router side, reinstalled and installed wordpress, so it can somehow read as the right Lan address. did everything it seems, and it can't come up.
  1. What was the reason for changing LAN ports?
  2. What did you change on the Netgear router?
  3. Are you using the Synology Version of WordPress?
  4. If you are not using Synology WordPress, in what folder is WordPress installed?
  5. Are you using a Virtual host?
I ask because normally the NAS automatically selects and uses the active LAN port. Are you using link aggregation?
Erasing all you files will not help if the server cannot be found.

When you changed to LAN2 did you also change the service order on the Network Interface page in DSM as well?

Since I'm not sure what you are trying to accomplish, one of these posts might help:
Help to access internet through lan2
Can I force an Application to use a specific Lan?

Post Reply