Wordpress MU, Apache & Domain Resolution

We installed wordpress MU on our linode and have been happily creating sites using MU's subdomain system. Our primary installation for MU is at openbluemu.com. So we went to take our first site live and found that it didn't resolve properly. Apparently MU will, if you point a CNAME to the main install, load up the appropriate blog. Well, we tried a CNAME for the subdomain version of the site and that didn't work either.

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

On some modern distros such as Ubuntu and Debian 5.0, the httpd.conf file is indeed blank, this is nothing to worry about. What distro is your linode running?

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 to if it isn't already.

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 :) but in theory with the above config, should be ok. Make sure apache's mod_rewrite module is enabled too, as Wordpress mu needs this to rewrite the request to the appropriate subdomain (accounted for with the 'wildcard' ServerAlias above).

Let me know how you go.

Condate,

Thanks for your detailed reply and help. Great avatar btw :lol:

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 www.jewelleryflow.com (you need to put in the www in the browser) with a CNAME to crownhill.openbluemu.com and, of course, it doesn't work.

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

ServerAdmin webmaster@localhost

DocumentRoot /var/www/

Options FollowSymLinks

AllowOverride None

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None

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/"

Options Indexes MultiViews FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

Allow from 127.0.0.0/255.0.0.0 ::1/128

openbluemu.conf

SuexecUserGroup "#1001" "#1002"

ServerName openbluemu.com

ServerAlias www.openbluemu.com

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

Options -Indexes IncludesNOEXEC FollowSymLinks

allow from all

AllowOverride All

allow from all

RewriteEngine on

RewriteCond %{HTTP_HOST} =webmail.openbluemu.com

RewriteRule ^(.*) https://openbluemu.com:20000/ [R]

RewriteCond %{HTTP_HOST} =admin.openbluemu.com

RewriteRule ^(.*) https://openbluemu.com:10000/ [R]

Alias /dav /home/openbluemu/public_html

DAV On

AuthType Basic

AuthName openbluemu.com

AuthUserFile /home/openbluemu/etc/dav.digest.passwd

Require valid-user

ForceType text/plain

Satisfy All

Hi,

So if I understand this right, you want the URL 'www.jewelleryflow.com' to arrive at the same content as crownhill.openbluemu.com ?

I thought it would just be a case of adding ServerAlias www.jewelleryflow.com to the openbluemu virtualhost config and then I realised, how would Wordpress mu know to direct to the correct blog in the multiuser system.. hmm. This ultimately is where the buck stops

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 www.jewelleryflow.com to crownhill.openbluemu.com, but that might be a messy fix?

RewriteCond %{HTTP_HOST} =www.jewelleryflow.com

RewriteRule ^(.*) http://crownhill.openbluemu.com/ [R]

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 www.jewelleryflow.com, you'd just add it as a Server Alias. Obviously this would want to be a special case - you don't want a separate vhost for every subdomain of wordpressmu, that'd be a nightmare.

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

I got it working but not by any particular cleverness. I simply moved the sites that were on the virtual servers that were ahead of the one with the wordpress installation. Then I deleted them, making the wordpressmu installation first on apache's list. With that virtual server first and the CNAME pointed to the mainwordpress blog, wordpress resolved to the correct site (I am supposing it got the domain from the http header and matched that with the matching domain listed in it's tables).

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.

Sounds strange though… let me give you an example of my Apache set up, where I can add virtualhosts with whatever name I like and Apache knows what to do:

(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 :)

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct