Quote:
Code:
lrwxrwxrwx 1 root root 56 Mar 30 10:29 sub-mydomain.com -> /etc/apache2/sites-available/sub.mydomain.com
This is crazy, the names don't match.
Have you made this symlink manually?
To put all info in one place:
0. You need a DNS entry for the domain and/or subdomain pointing to the server.
1. You should edit only the "real files" in /etc/apache2/sites-available/
2. To "activate" a site, you run
Code:
a2ensite file.name.here && invoke-rc.d apache2 reload
which creates a symlink in the sites-enabled directory and tells Apache to re-read config files.
3. To deactivate, similarly use
Code:
a2dissite file.name.here && invoke-rc.d apache2 reload
which removes the symlink and tells Apache to re-read config.
4. A file in /etc/apache2/sites-available can have any name (using the domain name it is for is a good idea though.)
5. It should look like that,in its simplest form:
Code:
<VirtualHost *:80>
ServerName sub.example.com
DocumentRoot /path/to/files/for/the/site
</VirtualHost>
You should not put the domain name on the VirtualHost line in most cases.
Just the ServerName line.
Of course it can have a lot other entries, setting up redirects, scripting, and stuff. We can share some examples if you wish.
6.
If your server is accessed by a (sub)domain name for which you do not have an explicit sites-enabled file, it'll show the first site that was configured.The sites files are loaded in alphabetical order.
So, you should create a sites file for a placeholder (or redirect) site that should be displayed in cases like accessing your server by IP (
http://1.2.3.4/), name it like 000default or ___default or similar, and enable it.