Jeremy Davis's picture

Personally if I were only planning on running one site (and didn't actually need to use a subdomain) then I would leave the config default and just dump the new site straight into /var/www. If you wanted to keep the TurnKey control panel, either rename it turnkey.html (and access it with http://mysite.com/turnkey.html) or move it to a directory like /var/www/admin (and access it with http://mysite.com/admin).

Also keep in mind that if you want to use subdomains then you'll need to have the DNS setup properly...

Also I haven't ever used the Webmin Apache module so I can't really talk to that... Glancing at it it seemed confusing to me and using the manual config way isn't too hard IMO. So without knowing exactly what Webmin Apache has done, this is what I did from a clean install of TKL LAMP

As a little background; I made the name resolution work by adding entries of admin.server and www.server to my local hosts file (pointing to the IP of my VM). I moved the contents of the /var/www directory (except for cgi) into /var/www/admin.server and created a new directory /var/www/www.server with a very basic index.html file inside so I could be sure it was working... I then copied the contents of /etc/apache2/sites-available/default to 2 new 'sites' (in that same folder) admin.server and www.server

In /etc/apache2/sites-available/admin.server I have:

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80> 
        ServerAdmin webmaster@localhost 
        ServerName admin.server 
        DocumentRoot /var/www/admin.server
</VirtualHost>

<VirtualHost *:443> 
        SSLEngine on 
        SSLCertificateFile /etc/ssl/certs/cert.pem 
        ServerAdmin webmaster@localhost 
        ServerName admin.server 
        DocumentRoot /var/www/admin.server
</VirtualHost>

<Directory /var/www/admin.server/> 
        Options Indexes FollowSymLinks MultiViews 
        Order allow,deny 
        allow from all 
</Directory>

And in /etc/apache2/sites-available/www.server I have:

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/www.server
        ServerName server
        ServerAlias www.server
</VirtualHost>

<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/cert.pem
        ServerAdmin webmaster@localhost
        ServerName server
        ServerAlias www.server
        DocumentRoot /var/www/www.server
</VirtualHost>

ScriptAlias /cgi-bin/ /var/www/cgi-bin/

<Directory /var/www/www.server/>
        Options Indexes FollowSymLinks MultiViews
        Order allow,deny
        allow from all
</Directory>

I then disabled the default site, and enabled my 2 new sites:

a2dissite 000-default
a2ensite admin.server
a2enstie www.server

Then reload Apache:

service apache2 reload

Apache complained:

root@lamp-v13 ~# service apache2 reload
[....] Reloading web server config: apache2[Sat Apr 12 07:31:35 2014] [warn] NameVirtualHost *:443 has no VirtualHosts
[Sat Apr 12 07:31:35 2014] [warn] NameVirtualHost *:80 has no VirtualHosts
. ok 

But testing confirmed that it worked... To resolve the warning just remove the first 2 lines from www.server. The virtual hosts have already been declared in admin.server and the 'sites' files are processed sequentially in alphanumeric order i.e. '0' comes before '1' and both come before 'a' (which comes before 'z' etc...)

The reason why I left them there is so that each file can be enabled/disabled individually, without breaking the other. E.g. to disable the 'admin' site but leaving the 'www' site active you would do:

a2dissite admin.server

I guess another way to go would be to make a separate site (in /etc/apache2/sites-available) with just the first 2 lines (and remove the matching lines from both of the existing sites). If you go that way, then I would suggest the new site (declaring the NameVirtualHost directives) starts with '00' (e.g. '00base') so that it is processed by Apache first (prior to the other sites that will rely on it).