Set up a Website on your Synology Server

steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

Set up a Website on your Synology Server

Post by steven »

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

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

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

Image

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

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

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

index.zip
(332 Bytes) Downloaded 2251 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.

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="#">
to

Code: Select all

<a href="/folder_name/">
or add an external link

Code: Select all

<a href="http://example.com/">
Comments were placed in the html file about lines to change. The example html page is shown below the download link.

My_Front_Page.zip
(1.21 KiB) Downloaded 1515 times
Created 4/14/20



Image

Last edited by steven on Mon Apr 13, 2020 6:53 pm, edited 2 times in total.
middlecee
Posts: 1
Joined: Fri Jun 01, 2018 3:12 pm

Re: Set up a Website on your Synology Server

Post by middlecee »

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.
steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

Re: Set up a Website on your Synology Server

Post by steven »

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 links might help:
Help to access internet through lan2
Can I force an Application to use a specific Lan?
bigjeans
Posts: 4
Joined: Mon Mar 30, 2020 9:47 am

Re: Set up a Website on your Synology Server

Post by bigjeans »

Hello,
In the end I managed to find someone who sensibly describes the whole procedure.
My problem is that I can't force my domain to point to the right folder on the Web Station. I will add that I do not want to use any CMS (Wordpres or Jomla)
My domain is www.worldweb.pl
The path to the page on the server is /web/worldweb/index.html
Currently, my domain is directed to a permanent IP and after loading it directs me to the main folder with an example page.
I also have a ssl certificate that is rewritten to my domain is installed on the server.
I am asking for help in this matter.
Regards.
d.jpg
d.jpg (272.85 KiB) Viewed 132711 times
dd.jpg
dd.jpg (226.34 KiB) Viewed 132711 times
ddd.jpg
ddd.jpg (155.98 KiB) Viewed 132711 times
Last edited by bigjeans on Mon Mar 30, 2020 12:54 pm, edited 1 time in total.
steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

Re: Set up a Website on your Synology Server

Post by steven »

You may have done this but I'll ask anyway, did you configure php?

Also your virtual host shows the domain as worldweb.pl but if you are using www the domain should be www.worldweb.pl.

When I click the link, in your post, I get this web site:


Image


bigjeans
Posts: 4
Joined: Mon Mar 30, 2020 9:47 am

Re: Set up a Website on your Synology Server

Post by bigjeans »

Hello,

So I was able to configure so that you can enter the page after and after writing this post:

That I could enter after
worldweb.pl
www.worldweb.pl
I added another virtual host, is this the correct practice?
e.jpg
e.jpg (451.06 KiB) Viewed 132696 times
ee.jpg
ee.jpg (444.05 KiB) Viewed 132696 times
DNS server 53 - I configured as in the picture, my main problem was also that in my home LAN I could not access the website after www.worldweb.pl. Somehow I managed to work around it or that's how it should look like.
eee.jpg
eee.jpg (456.11 KiB) Viewed 132696 times
Please, expand the first part of the sentence "Have I configured PHP" I don't know what you mean?

If it is that I have a contact form in the tab ... I have to say with regret that it does not work and unfortunately I do not know how to do it to make it work.

I use PHP Mailer and on hosting of my provider "nazwa.pl" everything worked and unfortunately it does not go.

I was thinking about PHP Mailer (SMTP) yet.

Please write what tips you have for me, should I improve something?
steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

Re: Set up a Website on your Synology Server

Post by steven »

First, I also use two virtual hosts in many cases where I desire access with www and without www using the same domain name. Keep in mind DNS servers match the domain name you enter in the virtual host to the ip address. If something is missing from the virtual host domain name, the DNS servers will never find it. If you register www.mydomain.com then that must be entered in the virtual host. If you registered mydomain.com and www.mydomain.com, you can set up two virtual hosts, one with www and one without. That way no matter what someone types in the browser search bar, the DNS servers will find your website. It makes a quite a difference if you register or enter www or not with a domain name.

With regard to configuring php, go to web station.The second selection is php settings. Here you enable the modules php will use. For example if you decide to use a database mysql must be enabled. If you use php mailer you will need to enable the mailparse and possibly imap if you want to use that protocol.
 
Edit:
Keep in mind if you have a virtual host that only uses a local LAN address, WAN (internet) users will not see your site. For WAN traffic, you need to setup a host so port 80 and/or 443, for SSL, point to your site.
Last edited by steven on Tue Mar 31, 2020 10:38 am, edited 1 time in total.
bigjeans
Posts: 4
Joined: Mon Mar 30, 2020 9:47 am

Re: Set up a Website on your Synology Server

Post by bigjeans »

I have enabled these two functions in PHP
mailparse and imap
But it probably requires configuration, have you already worked on this topic?

Do you have any tips on exactly what steps to take, what changes to make for PHP mailer to work?
steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

Re: Set up a Website on your Synology Server

Post by steven »

Although I use phpmailer, I am not an expert on the subject. I am not aware of any user configuration requirements for mailparse or imap. These modules are usually included when php is compiled.

If you have users that access DSM, Synology has a mail program allowing users to send emails. However, if you want to use email from web pages you must use or write a program to do that. This is one reason why many use a CMS like WordPress or Joomla.

Since the internet can be a dangerous place, filters are necessary to prevent malicious code from infecting your server or possibly emailing to others. Writing a safe email program can get a bit complicated when allowing attachments. Attachments are typically uploaded to your server before sending, so you need to make sure they are safe.

To get started, checkout this tutorial on phpmailer.
bigjeans
Posts: 4
Joined: Mon Mar 30, 2020 9:47 am

Re: Set up a Website on your Synology Server

Post by bigjeans »

I understand that you use CMS (Wordpres, Jomla)?
Thank you for sending links, however my knowledge of PHP is weak :(

I described the situation in the help of synology, maybe they will tell me how to do it and give a ready solution to the problem.

Thank you for being interested in my problem and wanting to answer my questions.

Regards Krzysztof
Post Reply