The following is the basic procedure for installing WordPress mu with more than one domain name so that you only need one install to control several domains. I’m creating this document to help me see all the steps I’ve take so that I never have to figure it out from cold again and to help me with the writing of a plug-in that will allow me to do this via a very simple interface.
- Install mu on your domain {e.g. yourdomain.com} and ensure that wildcard domains are processed by mu. Entering [ramdom].yourdomain.com should take you to a prompt to create a blog of [ramdom].yourdomain.com unless it already exists that is.
- Park the new domain {e.g. newdomain.com} using your servers management back end. This will be different on each hosting provider and may not even be available so if it is not obvious you’ll need to contact your provider.
- Create a new blog {e.g. newdomain.yourdomain.com} and test it.
- Get into a position where you can edit the db.
- Run
SELECT * FROM wp_blogs WHERE 1
and look for the blog you just created and make a note of its blog_id. - Edit the domain cell. Will currently be set to newdomain.yourdomin.com and we want to change it to newdomain.com. If we assume the blog_id is 9 the following command would do.
UPDATE wp_blogs SET domain="newdomain.com" WHERE blog_id =9 LIMIT 1
- We now need to edit the other references to the sub-domain and point them to the real domain name. If you run the following you will find 3 references back to http://newdomain.yourdomain.com change them to http://newdomain.com/ and be sure to keep anything that comes after the domain name. i.e. /files/. Again we assume the blog_is is 9
SELECT * FROM wp_9_options WHERE option_value LIKE "http://%"
- Your site should almost work at this point. Give it a test, you should find it all looks as you expected until you try to login to the backend. That is what we’ll fix next.
- We need to add a new site to the wp_site table so that we can use the backend admin.
INSERT INTO wp_site (id,domain,path) VALUES ("9","newdomain.com","/");
We can use the blog_id as the value for id if it has not been used before, if it has been used then just pick a number that’s not been used and make a note of it. The value of domain should be that of the new domain {e.g. newdomain.com} and the value of path should normally be “/”. - We now need to go back to the wp_blogs table
SELECT * FROM wp_blogs blog_id = 9
and edit the site_id to be that of the id we set up in step 9. So that would beUPDATE wp_blogs SET site_id=9 WHERE blog_id =9 LIMIT 1
. Change the site_id to that which you previously chose if it is not the same as the blog_id. I like to keep them the same to aid my admin but there is no technical need to do so. - Site meta needs to be configured to allow administrators to change the site settings. This command will set the user called admin as site_admin if site_id == 9
INSERT INTO wp_sitemeta (site_id,meta_key,meta_value) VALUES ('9','site_admins','a:1:{i:0;s:5:"admin";}');
If you need to change the admin name to something else, say “administrator”, you will have to change the s:5 to match the size of the new word. In the case of “administrator” it would be set to 13. - To enable site plugins the following is needed.
INSERT INTO wp_sitemeta (site_id,meta_key,meta_value) VALUES ('9','menu_items','a:1:{s:7:"plugins";s:1:"1";}');