domain with www and without www
The problem:
mydomain.com <--- goes to default virtualhost which is not correct
I have a fresh Debian 6 vps with very basic stuff on it right now( LAMP ), I am also using a sub domain *.mydomain.com which works perfectly fine.
My default virtualhost has not been modified at all and is the default, mydomain.com virtualhost file is created exactly as instructed in the tutorial http://library.linode.com/lamp-guides/debian-6-squeeze
I have done a lot of searching over the past few days that I have been trying to figure this out including reading every single topic I could find on this forum about it. I have attempted every single possible solution I could find to the best of my abilities with no success.
I even contacted my domain provider to have them verify my A records and other records to make sure I didn't mess anything up in the process and they assured me that everything is perfectly fine.
So the conclusion is that I am obviously missing something but I am just not sure what and I would appreciate any help on this.
11 Replies
apachectl -S
please?
It sounds like you've provided "ServerName
Apache allows you to put a "ServerAlias" in the vhost, putting subdomains and other domains in the ServerAlias will tell apache that any connections to these "aliases" go to the same place as the main domain that you want have the vhost for.
If that's not the issue, we need to have your vhost config files. Depending on what the actual issue is, we might need the main apache configuration file, though I doubt this will be the issue since apache already seems to be working.
–-------------
VirtualHost configuration:
wildcard NameVirtualHosts and default servers:
*:80 is a NameVirtualHost
default server mydomain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost mydomain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost mydomain.com (/etc/apache2/sites-enabled/mydomain.com:1)
Syntax OK
<virtualhost *:80="">ServerAdmin webmaster@mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /srv/www/mydomain.com/public_html/
ErrorLog /srv/www/mydomain.com/logs/error.log
CustomLog /srv/www/mydomain.com/logs/access.log combined
ErrorDocument 404 /missing.php</virtualhost>
apache2ctl -t -D DUMP_MODULES
core_module (static)
logconfigmodule (static)
logio_module (static)
mpmpreforkmodule (static)
http_module (static)
so_module (static)
alias_module (shared)
authbasicmodule (shared)
authnfilemodule (shared)
authzdefaultmodule (shared)
authzgroupfilemodule (shared)
authzhostmodule (shared)
authzusermodule (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
status_module (shared)
Syntax OK
linode DNS manager a/aaaa record should have one blank hostname entry and another for www Other than that the ServerAlias Should work with default install of apache on debian squeeze. copy both and replace ip address with ipv6 if you use that also.
What Apache is currently doing is using the config in "/etc/apache2/sites-available/default" to serve the domain "mydomain.com".
If you don't need this default vhost (which from the looks of it, you don't) then you can simply do the following:
a2dissite default && unlink /etc/apache2/sites-available/default
The default vhost is simply the one that Apache comes across first in it's configuration, you don't need one called "default". This is just a Debian convention.
I have done nothing else since my last attempt and now I am scared to mess with it because I will probably break it, for now I think it is best to leave it as is while it is working because I still have a ton of other things that I need to do to this VPS to get it up and running.
Even thought I have no idea what was done that magically fixed it( yes it is magic ) I would still like to say thanks to everyone who assisted me.
@AlecC: I did not edit my default and it is still up and running.
(edited to correct myself)