Sam Ashcraft's picture

I just installed a new turnkey LAMP server, and everything seems to be working great. However the Control Panel page comes up whenever I try to browse to my domain, no matter what I do.

I moved the contents to the /var/www folder (containing the Turnkey LAMP Control Panel) into subfolder (lets call it admin.mysite,com) and I dumped my website into the /var/www/www.mysite,com folder, and setup the Apache virtual hosts for each. I also placed a simle index.html file in /var/www for testing purposes. I the directory looks like this:

/var/www/admin.mysite,com
/var/www/www.mysite,com
/var/www/index.html

Apache is set for www.mysite,com to respond to any address on any port. admin.mysite,com is ony supposed to respond to admin.mysite,com on any port.

Here are the conf files generated my webmin

<VirtualHost *>
DocumentRoot /var/www/www.mysite,com
<Directory "/var/www/www.mysite,com">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

 

<VirtualHost admin.mysite,com:*>
DocumentRoot /var/www/admin.mysite,com
</VirtualHost>

I am most likely missing something really basic here, but no matter how I set it up, the Control Panel always shows up when I go to www.mysite,com, even when I tell the admin.mysite,com to only listen to a specific port. The only way I have been able to access anything other then the control panel is to remove the files compleatly. 

In short; I would like to serve out my own website, with the Control Panel only accessable via a sub domain. How can I accomplish this? 

BTW, I had to replace the . in the urls with a , to get around the spam filter. I guess it thought I was posting links or something. Sorry if it looks weird.

Forum: 
Tags: 
Jeremy Davis's picture

For Apache to use an updated config (e.g. like adjusting virtual hosts) you need to at least reload Apache.

service apache2 reload

or

service apache2 restart
Sam Ashcraft's picture

I guess I should have mentioned that I have been restarting apache after each change. I even rebooted the whole server a few of the times just to make sure. If I didn't know better I would say it was something in that control panel page overriding Apache own config files.
Jeremy Davis's picture

Also it may be worth clearing your browser cache too

I'll have a quick look and post what I find...

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).

Add new comment