Subdomain, what am I missing?
host sub.itsbetterintheoven.com
shows 72.14.188.138, as it should.
On the server side, in addition to my file for the main domain, I have sub.itsbetterintheoven.com with the following information:
<virtualhost 72.14.188.138:80="">ServerAdmin myemail@address.com
ServerName sub.itsbetterintheoven.com
ServerAlias www.sub.itsbetterintheoven.com
DocumentRoot /srv/www/sub.itsbetterintheoven.com/public_html
ErrorLog /srv/www/sub.itsbetterintheoven.com/logs/error.log
CustomLog /srv/www/itsbetterintheoven.com/logs/access.log combined</virtualhost>
I've run a2ensite on the file, and I've restarted apache. What gives?
10 Replies
You seem to be confusing IP-based virtualhosts with name-based virtualhosts… which happens often, for they're counterintuitive.
IP-based vhosts:
<virtualhost 1.1.1.1:80="">ServerAdmin myemail@address.com
ServerName example.com
ServerAlias www.example.com
# DocumentRoot, logs, whatever</virtualhost>
<virtualhost 2.2.2.2:80="">ServerAdmin myemail@address.com
ServerName sub.example.com
ServerAlias www.sub.example.com
# DocumentRoot, logs, whatever</virtualhost>
Name-based vhosts
NameVirtualHost *:80
<virtualhost *:80=""># First namevhost for this IP(or wildcard), will be selected
# if the user agent did not supplied Host: header
ServerAdmin myemail@address.com
ServerName example.com
ServerAlias www.example.com
# DocumentRoot, logs, whatever</virtualhost>
<virtualhost *:80="">ServerAdmin myemail@address.com
ServerName sub.example.com
ServerAlias www.sub.example.com
# DocumentRoot, logs, whatever</virtualhost>
Or, instead of *:80 you can specify one, and the same IP for a name vhost group, so you can have some namevhosts at one IP, and others at other. Matching there is done one the ServerName and ServerAlias lines.
The IP address that I listed above was simply to regard that my subdomain seemed to be pointing to the correct IP address.
kmw@charliebrown:~$ dig www.sub.itsbetterintheoven.com
; <<>> DiG 9.4.3-P4 <<>> www.sub.itsbetterintheoven.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 52181
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;www.sub.itsbetterintheoven.com. IN A
;; AUTHORITY SECTION:
itsbetterintheoven.com. 86378 IN SOA ns1.linode.com. kenneth.tdpowerskills.com. 2010021171 14400 14400 1209600 86400
;; Query time: 1 msec
;; SERVER: 74.207.241.5#53(74.207.241.5)
;; WHEN: Mon Feb 15 17:10:40 2010
;; MSG SIZE rcvd: 117
````
Note that there's no "ANSWER SECTION"; this is because
Now, sub.itsbetterintheoven.com does work, as does
To the OP: was this ever resolved?
EDIT: Ok, I got mine fixed. I realized I was supposed to be using a "CNAME" record instead of an "A" record. D'oh! Maybe this will help out.
I tried setting a cname with a host name of "radiant" aliased to "bobby-marko.com" and that didn't work so I tried aliasing "radiant" to "radiant.bobby-marko.com" and that didn't work either. My original attempts were with the A record host name set to "radiant" and the IP address set to my Linode IP.
What am I doing wrong?
Here's my main domain virtual host:
<virtualhost 74.207.233.205:80="">ServerAdmin xxxx@xxxx.com
ServerName bobby-marko.com
ServerAlias www.bobby-marko.com
DocumentRoot /srv/www/bobby-marko.com/public_html/
ErrorLog /srv/www/bobby-marko.com/logs/error.log
CustomLog /srv/www/bobby-marko.com/logs/access.log combined</virtualhost>
and my sub domain:
<virtualhost 74.207.233.205:80="">ServerName radiant.bobby-marko.com
ServerAlias *.radiant.bobby-marko.com
DocumentRoot /srv/www/radiant.bobby-marko.com/public/
<directory srv="" www="" radiant.bobby-marko.com="" public="">Allow from all
Options -MultiViews</directory></virtualhost>
Sorry if I'm making some huge mistake somewhere, I'm new to all of this. I also tried disabling the default site virtual domain file and I saw no change so I enabled it again.
Thanks
-Bobby
Regarding your actual issues, I don't know Apache, and I've got no idea.