TurnKey Linux Virtual Appliance Library

Virtual Host Not Resolving

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

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 :
http://10.11.1.157/test.jay

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

Jeremy's picture

Not quite how it works...

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 http://10.11.1.157/test.jay is set up an alias, something like this:

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

Clairification

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's picture

No worries :)

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

not following your goal...

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

Director

Specialised Technologies

Check the virtual machine network configuration.

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.


Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)