Install Multiple Websites: Difference between revisions

From QNAPedia
Jump to navigation Jump to search
(Undo revision 1131163 by Hecc1 (talk))
 
m (1 revision imported)
 
(No difference)

Latest revision as of 17:51, 16 June 2015

How to setup multiple web sites / domains on QNAP

courtesy of willyhoops


  • Setup your two domains so they point to your static ip address and wait until the changes are working (eg 24hours). You know the changes are working becuase if it's right then typing either url into IE will direct you to the web site you have on Qnap.
  • Now make directories for you web sites. I have one stored at Qweb and one stored at Qweb\whooper. But you might prefer Qweb\site1 and Qweb\site2. Make sure they both have index.htm files or whatever and test them if you can by typing http://qnap_ip/site2 or whatever.
Make sure you have the latest QNAP firmware and install WinSCP (Goto http://winscp.net/eng/download.php and click the installation package).
  • Open WinSCP, enter you qnap ip address, username admin, your admin password, leave file transfer as the default and click save. Now click login. You see the system files on your qnap. Now go up to the root directory and then goto the directoy /mnt/HDA_ROOT/apache/conf/. Now find the apache.conf file, right click on it and select edit. Scroll to to the bottom and add the lines
<VirtualHost *>
ServerName willyhoops.com
ServerAlias www.willyhoops.com
DocumentRoot "/share/Qweb"
</VirtualHost> <VirtualHost *>
ServerName willyhoops.co.uk
ServerAlias www.willyhoops.co.uk
DocumentRoot "/share/Qweb/whooper"
</VirtualHost> 


  • change as you need and click save (floppy disc) icon on the toolbar.

NOTE by the way we have forward not back slashes in the DocumentRoot paths.

  • You could reboot the router now from the web interface and wait a few minutes, but it's quicker to now click Commands then Open Terminal in WinSCP and then type " /etc/init.d/Qthttpd.sh restart " into the box and then press Execute. This will restart apache and print any error messages to the screen. I get this little one which is nothing to worry about "Could not determine the server's fully qualified domain name using 192.168.0.103 for ServerName", but then it goes on to say "httpd started".
  • Now type http://www.willyhoops.com and http://www.willyhoops.co.uk or whatever into IE and be amazed that it works.

That's all you need to do hey presto!! There is no limit to the number of web sites you can host this way as far as I know, and you don't need to purchase extra IP address or worry about DNS C records or any of that stuff that some of the apache virtual host for dummies / idiots articles i read mention.

PS The stuff about startup scripts and the config file changing back on a reboot is a red herring - it's ok for this change as it happens.

PPS This technique does not work with really ancient browsers, and they would end up back at you Qweb root directry - however, you don't need to worry becuase no one is running these ancient versions anymore.

PPPS If you want to create intranet only web sites for testing ideas before you go and publish them for real you can use this technique as well. Edit the hosts file in \windows\system32\etc and under the localhost line add the line "127.0.0.1 mytestsite.com". Then add mttestsite.com to the apache.conf file as above and after QNAP has rebooted you can see it by typing http://mytestsite.com into IE. Do not type http://www.mytestsite.com or you will end up on the internet looking for that real domain.


Addition

courtesy of henderson1977

To make both websites work on the local network.

  • Map the static IP address of the NAS to the domain name in the hosts file located at C:\Windows\System32\drivers\etc\, for example:-

192.168.1.100 http://www.domain1.co.uk
192.168.1.100 http://www.domain2.co.uk

  • To make sure both websites work externally:

Access your router configuration webpage and forward port 80 to the IP address of the NAS (e.g. 192.168.1.100) and test it works externally (e.g. from work).

Another option for TS109

Courtesy of efeene

On mine TS109 (last 2009 firmw) this method rewrites the default directive DocumentRoot.

Works fine with this:

NameVirtualHost *

<VirtualHost *>
DocumentRoot "/share/Qweb"
</VirtualHost>

<VirtualHost *>
ServerName server1.host.org
ServerAlias www.server1.host.org
DocumentRoot "/share/Qweb/server1"
</VirtualHost>

<VirtualHost *>
ServerName server2.host.org
ServerAlias www.server2.host.org 
DocumentRoot "/share/Qweb/server2"
</VirtualHost>
  • Go to the botton of apache.conf and add this directives, and of course make your changes.
  • If you remove the comment symbol "#" in ServerName and add something for yor server name, (e.g. ServerName MyServer), it will not appear any error when you restart the server. But this error is not a problem.
  • I also remove the comment symbol "#" in BindAddress * , this will facilitate the server for listen all connections on every IP address or any fully-qualified Internet domain-name. Good if you work with diferent IP address / domains.
  • In my case I use a DDNS service like dyndns.org and use the option "create wildcard alias for domain". This means you only need to create one domain and use as many alias you need. And of course if you only have the DDNS of QNAP TS dont need to worry in update many DDNS domains.

Hope this help.

NameVirtualHost *:80

After adding the wanted number of virtual hosts and restarting Apache, you might come across the error message:

VirtualHost overlap on port 80, the first has precedence 

This can be corrected by adding the line:

NameVirtualHost *:80 

in the apache.conf file.