Forum: 

Virtual hosts

satman1w's picture

I have downloaded .iso, installed it in VMWare ESXi environment, and it works.

What I need is several websites on same IP and port but with different host header.

Turned the internet upside down and there is no useful cookbook for Turnkey LAMP.

 

Am I right or blind??

 

Thanks

Jeremy Davis's picture

Under the hood, TurnKey is Debian, so any instructions you find for Debian apply just as well to TurnKey. v14.x = Debian Jessie.

And as you would expect, TurnKey LAMP includes Apache (that's the 'A'). And the version of Apache in TurnKey v14.x is Apache 2.4, so the Apache docs themselves are probably your best bet. So the page you were looking for is name based virtual hosts. You may also find the virtual host examples quite useful?

The only thing to keep in mind is that Debian rearrange things a little, so instead of having a great big monolithic httpd.conf with all the apache config in it, Debian splits it up a bit.

So probably what you will want is to create a new separate domain site config file for each virtual host in /etc/apache/sites-available/. Unless you are really clear what you need to do, I recommend that you copy the default virtual host as a basis (then edit each to reflect what you are serving).

Assuming that you wanted to serve 2 domains; mysite1.com and mysite2.com, this is how I would do it:

cd /etc/apache/sites-available
cp 000-default.conf mysite1.com.conf
cp 000-default.conf mysite2.com.conf
cd -
Then edit those sites so they look as you intend. I can't anticipate exactly what you want (and I'm not that much of an Apache expert that I could reliably tell you how to configure it OTTOMH anyway) so I'll leave working that out to you. But please feel free to post back with further questions and I'll do my best. Don;t forget to update the document root directories (see below).

Assuming that you are serving html or php content, you'll also want to create the document root directories for them. I recommend sticking with convention and putting them in /var/www. So something like this:

mkdir /var/www/mysite1.com
mkdir /var/www/mysite2.com
Then upload your content into the relative directory. Finally assuming that all goes smoothly, you may also want to give your webserver full ownership of your doc roots (note, this does have security implications, but as per always, it's a tradeoff between security and ease-of-use).

The final step will be to disable the default site and enable your new sites:

a2dissite 000-default 
a2ensite mysite1.com
a2ensite mysite2.com
service apache2 reload

Then if got it all right, everything should be working as you expect! Fingers crossed!

Good luck with it all and please post back and let us know how you go. If you are struggling, please feel free to ask. THe more info you can share, the better.

Post new comment