Hello all,

I have recently installed a new virtaul machine using the TurnKey Linux LAMP appliance. The setup was successful but I am having trouble creating virtual hosts.


I followed the advice on the post found here: http://www.turnkeylinux.org/forum/support/20111129/lamp-virtualhost-name-based . My virtual host file looks like this:

<VirtualHost *:80>
        ServerName test.jay
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/test/html

The directory /var/ww/test/html contains one file, index.html, which has a bit of markup in it to let me know the page loaded successfully.

I ran a2ensite and my site was added to the sites-enabled directory. I restarted Apache and navigated to :

but I got a file not found error. Could anyone suggest what I am doing wrong? Any suggestions are appreciated. Thanks much.

Jeremy Davis's picture

I'm certainly no expert on these things but you need to set up DNS too. You'll need to point the domain name test.jay to your server IP and then browse to http://test.jay

I think the other thing you could do if you want to use is set up an alias, something like this:

Alias /test.jay /var/www/test/html/

Thank you for the reply,

What I am doing is running the Turnkey server as a virtual machine and browsing to it from the host machine, do I need to make modifications on my host machine to make this work? Is that where I would have to do the DNS changes(is this a hosts file thing? )?

Thanks again for the reply, I appreciate your help here.

Jeremy Davis's picture

Yep adding an entry to your hosts file should do the trick!

If you want others to be able to use the domain though you'll need to have a nameserver (DNS) with an entry that points to your IP. If you want this for internal use then you can set up your own DNS (you could even install it to your existing TKL server or setup another VM). Otherwise most domain hosts can sort that for you.

Chris Musty's picture

Four questions as I am not sure what your trying to do...

Are you simply trying to achieve a web server with the TKL LAMP stack?

How did you install a virtual machine - Baremetal, Proxmox, AWS, other third party host?

Are you on a LAN or WAN?

Do you want to resolve a domain to your server?

Chris Musty


Specialised Technologies

If the network configuration of VM is in a NAT mode you need to switch to a bridged mode. That way the lamp VM will be on the same subnet as the host computer. Of course, the port 80 tcp needs to be forwarded to the lamp vm machine.


Here is how i do vhosts via webmin:

Go to your Webmin control panel.
Servers -> Apache WebServer.
In the 'Create a New Virtual Server' section select "Any Address" (so you do not end up with a hard coded IP addresses in your conf file). Enter 80 for Port (and select the last radio button).  This way the VirtualHost will co-exist with  any SSL-enabled virtual hosts you add later on.  SSL-enabled VirtualHosts need to listen on port 443.
 In the "Document Root" field enter where the virtual host HTML files will be.  For example, /home/vhostdomain.com/htdocs.
For "Server Name" enter the domain name for which you want to serve pages.  e.g. "vhostdomain.com"

After you have created the Virtual Host, click on the Virtual Host, and go to Networking and Addresses. Enter an "Alternate virtual server names" of *.YourOtherDomain.com. 
With this setting, your virtual host will serve pages for http://yourotherdomain.com/ as well as http://www.yourotherdomain.com/.

At this point you may also wish to set other options like "Log Files", so the log files
for the Virtual Host end up in separate log file from the main server's log files.

To activate your changes, click "Apply Changes" on the main Apache Webmin page.

Of course, be sure to configure your DNS server so the virtual host domain name points to your server's IP address.


The above instructions are copy paste from here.


Have fun.

Add new comment