Setting up virtual host to allow 2 different websites, with different DNS providers

Operating System: NethServer release 7.7.1908 (final)
Kernel Release: 3.10.0-1062.18.1.el7.x86_64
Application: Web server v 3.8.1

Hello everyone,

I hope everyone is having a good evening.

I have been running NethServer for a longtime. I also have been running a website from it as well. I am wanting to bring up a 2nd website on the same server.

I am not going to put the name of my websites, just name holders…
To be able to reference the 1st website lets just say my 1st website is myweb1.com
To be able to reference the 2nd website lets just say my 2nd website is myweb2.com

My first website is running under Web root path - /var/www/html/ (Would others recommend running the main website as the default path? if not please let me know why.)

I use register.com for myweb1.com and godaddy for myweb2. Obviously I have myregister.com setup correctly in register.com.

So the first website seems to work fine. I even have Webtop running and I can connect via main website. http://myweb.com/webtop/

In NethServer, I have gone into >Applications>Website settings>Virtual hosts

I created a virual host - myweb2.com gave it a discription and selected create.
the web root path for myweb2.com on nethserver is - /var/lib/nethserver/vhost/59f3a47b4503d32/

I am trying to get my second website myweb2.com to show up on the internet. I have already allow it to propogate on internet from nethserver and godaddy are correct.

I know it requires some possible A,SRV,CNAMES that point it back to the nethserver and the FQDN of the site. Possibly on both godaddy and nethserver.

Here is what I have setup already. For godaddy I purchase a domain, then I setup the following records for myweb2 -

Type…Name…Value…TTL
A …@…111.111.111.111…1/2 (IP ADD shown not real one)
A … *…111.111.111.111…1/2 (IP ADD shown not real one)
CNAME…www…@…1/2

I have let it replicate more then 24 hrs.

When I go to www.myweb2.com. I get the www.myweb1.com website that comes up.

Thanks,
-SF-

DNS should be ok when myweb2 shows myweb1.
It seems the virtual host name (the domains) of myweb2 is not correct. If the host you enter in browser does not match the virtualhost name or you use the IP address you’ll see the default site.
Did you upload some files to the virtualhost?

The virtualhost module is designed to run websites with different settings(php, cert etc.) so I’d recommend to run the sites with it.

oops! yes the 111.111.111.111 is not the real ip. It is also an example (filler). Sorry, I should have said something about that.

So virtual host created the following root folder for the website2 at - /var/lib/nethserver/vhost/59f3a47b4503d32/ and I placed a website in that directory with a index.html file.

This virtual host seems to be very basic and run a bit different because I have run virtual host in the past and I was able to run more then one site, the challenge was going into the configuration file and setting up the correct setting for ip, server paths, URL and so on. Nethserver website virtual host seemed to create a virtual host folder, but I can not see where to put in the settings that I would normally have control over in apache configs.
Like the following link -
https://httpd.apache.org/docs/2.4/vhosts/examples.html

I figured it would be simpler with Nethserver website virtual host and be all GUI based. I must be missing something…

Thanks,
-SF-

No problem but you shouldn’t use IP at all as the virtualhost only comes up when you use the name.

Maybe you need to set permissions?

It always depends on the site you are using but for testing you could try

chown -R apache:apache /var/lib/nethserver/vhost/59f3a47b4503d32/

Many options are provided in advanced settings at vhost creation:

To add configuration manually you may use a .htaccess file.

2 Likes