Wordpress MU, Apache & Domain Resolution
So we're having problems with the way apache is resolving (or rather not resolving) a domain to our virtual server. We created test.crownhillpackaging.com with a CNAME for openbluemu.com. However, if you go to that test address it resolves to one of our other virtual servers. It seems to have something to do with the virtual servers' creation date. I deleted the virtual server it was initially resolving to and then it just started resolving to the next one in the list – and not the one it should be resolving to.
Oh and the /etc/apache2/httpd.conf file is empty. We had a suggestion to move the openbluemu virtual server to the top of the list but the 'list' doesn't exist in that file.
Thanks,
Robin.
5 Replies
Key files are /etc/apache2/apache2.conf, /etc/apache2/ports.conf and /etc/apache2/sites-available/default
The vhost config for your wordpress mu domain should look something like this:
<virtualhost *:80="">ServerName openbluemu.com
ServerAlias *.openbluemu.com
DocumentRoot /path/to/wordpressmu/installation
<directory path="" to="" wordpressmu="" installation="">AllowOverride FileInfo Options</directory>
....</virtualhost>
You might need other stuff in there where necessary.
Edit your /etc/apache2/sites-available/default file and change
in one of the three files I mentioned at the top of this, there should be an entry 'NameVirtualHost *:80'. In my Debian Lenny VPS, this is in the ports.conf. It doesn't matter where, as long as it only occurs once.
In theory this setup should work, as well as allow you to add other vhosts with different domains altogether i.e your crownhillpackaging.com domain, by creating a new vhost with
<virtualhost *:80="">ServerName crownhillpackaging.com
ServerAlias www.crownhillpackaging.com
... and so on</virtualhost>
If you're still having trouble, paste in the contents of your /etc/apache2/sites-available/default file and anything else that might be of use, i.e any errors that are reported on stdout when you reload Apache, and so on..
Note that I haven't got a wordpress mu site running with subdomains either, I was just reading the instructions in the documentation
Let me know how you go.
Thanks for your detailed reply and help. Great avatar btw
So I played around with this a little bit and tried to get some support from my provider. There was (on their part) some confusion about the fact that I was using a subdomain test.crownhillpackaging.com so I've changed things a bit so it should be more clear. The site I need to make live is at crownhill.openbluemu.com and once i get this sorted I need to connect it to crownhillpackaging.com but for testing purposes I'm using a spare domain so I have set
In my /etc/apache2/sites-available there is a .conf file for each domain and another that says default. I have pasted the default conf and the openbluemu conf.
So the trick seems to be how to tell apache to direct the traffic. At this point, I'm not even going to worry about whether or how wordpress handles the resolution once it gets the traffic because I'm not even that far yet. All I want for now is to get this CNAME to work.
So that's kind of where I am right now. I'm really looking forward to your response.
Thanks,
Robin.
default.conf
NameVirtualHost *
NameVirtualHost 97.107.131.120:80
DocumentRoot /var/www/
AllowOverride None
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
Possible values include: debug, info, notice, warn, error, crit,
alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
openbluemu.conf
ServerName openbluemu.com
ServerAlias
ServerAlias webmail.openbluemu.com
ServerAlias admin.openbluemu.com
ServerAlias *.openbluemu.com
DocumentRoot /home/openbluemu/public_html
ErrorLog /var/log/virtualmin/openbluemu.comerrorlog
CustomLog /var/log/virtualmin/openbluemu.comaccesslog combined
ScriptAlias /cgi-bin/ /home/openbluemu/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
allow from all
AllowOverride All
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.openbluemu.com
RewriteRule ^(.*)
RewriteCond %{HTTP_HOST} =admin.openbluemu.com
RewriteRule ^(.*)
Alias /dav /home/openbluemu/public_html
AuthType Basic
AuthName openbluemu.com
AuthUserFile /home/openbluemu/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
So if I understand this right, you want the URL '
I thought it would just be a case of adding ServerAlias
One way you could do this, is add that domain as a ServerAlias like I said above, then you could use another rewrite rule in that config to rewrite
RewriteCond %{HTTP_HOST} =
RewriteRule ^(.*)
The ultimate point here is, your DNS seems ok, your Apache vhost config looks quite sane (maybe some redundancy in the default config as all requests to your IP default to the other vhost anyway, but thats ok for now).. I think redirecting a totally different URL to a specific blog within wordpress mu might be trouble, and that's mainly due to the way Wordpressmu is meant to work..
The alternative I guess, could be to have a separate vhost config specially for crownhill.openbluemu.com so that you don't have to rewrite the URL to this for requests to
On the other hand, I'm not sure if the ServerName crownhill.openbluemu.com in a separate vhost, would overrule the wildcard in the main openbluemu.com domain? Actually not sure of how Apache would deal with that, but am looking it up..
So the wordpress mu site is at openbluemu.com and given that apache seems to do it's round-robin in alphabetical order, I guess I can only add new virtual servers that would (alphabetically) occur after openbluemu
I would still like to figure this out. But I had a deadline that had to be met. But looking forward to any additional light you can shed on this. You've been super-helpful, and I'm very grateful.
Kind regards,
Robin.
(default conf)
NameVirtualHost *:80
<virtualhost *:80="">(general default stuff here, no ServerName)</virtualhost>
example.com virtualhost:
<virtualhost *:80="">ServerName example.com
ServerAlias www.example.com live.example.com
(etc etc)</virtualhost>
another.com
<virtualhost *:80="">ServerName another.com
ServerAlias www.another.com blog.another.com
(etc etc)</virtualhost>
I've heard this roundrobin approach mentioned before and I've never seen it.. maybe it's because I don't understand Apache all that well, but as far as I could tell, with a setup per above it just uses whatever the first config file it can find with a matching host in ServerName / Server Alias, doesn't know anything about the order of the configs or the alphabet
I can't really explain it but I think the key difference is using Name based VirtualHosts as per above rather than IP-based virtual hosts.
I've just been reading this to try and explain it, in doing so I've learnt a bit