Setup WordPress Multiple Site Using Subdomains on VIrtualmin

Wordpress multi site using subdomain

WordPress multi site using subdomain

I keep on seeing a few multi-site WordPress installation using a sub directory but a few have a multi-site using a subdomain. Firing up curiosity, I tried installing a one using subdomains instead.


Setup WordPress Multiple Site Using Subdomains on Virtualmin

The very first step is to load up your editor and edit wp-config.php, you need to add this small line of code

You need to logout and relogin after doing this change, after relogging, you will get a new menu under tools called “Network Setup”. Make sure that you disable all your plugins before proceeding.

You need to check the permalinks first under settings menu then proceed to to setup the network, since this is a subdomain approach, select subdomain in the network type. WordPress will complain that your DNS is not setup properly, you can literally ignore this if you want to generate the subdomain aliases manually.

Upgrading wp-config.php

To complete the setup on WordPress side, you need to edit your htaccess file and wp-config.php file.

Upgrading .htaccess file

To complete the setup, make sure that this items exist on your .htaccess file

Completing the update on the server

The not so hard way

You need to add a domain alias on your httpd.conf file and add a server alias

This ServerAlias instructs the server to point all subdomains.domain.com to domain.com if they are not setup. Make sure you made a backup with http.conf since this can mess up your domain hosting if done wrongly.

Next step won’t be pretty for some since we are now going to modify our DNS, some people have no control on the DNS or the DNS host won’t allow a wildcard domain. If your host or domain provider won’t allow a wildcard domain, contact them and ask them to set it up for you.

Just wait for the DNS to reload and viola, you can now add a new site called site1.domain.com without creating a subdomain..

The easy way using Virtualmin

Open up virtualmin and goto Webmin->Server->Bind DNS -> domain.com

Editing our DNS

Editing our DNS

Click “Edit Records File” to open up our DNS editor.

Open up virtualmin and goto Webmin->Server->Apache WebserServer -> domain.com 

Open up “Edit Directive” and add the ServerAlias line.

 

Add a wildcard alias in the conf file for our virtual server

Add a wildcard alias in the conf file for our virtual server


The Totally Easy and Lazy Way.

Virtualmin uses subservers instead of subdomain, the difference is great since Virtualmin’s subservers can have their own set of everything on default. Own email, own https certificate, own FTP, own mail records and other stuff. We are going to leverage this on our benifit.

Goto Virtualmin->Server Options->Website Options.. look for the “Website matches all sub-domains?” and tick “Yes”. This instructs Virtualmin to treat all subdomains as an alias for domain.com, the good thing, Virtualmin will setup the DNS and the httpd.conf for you.

 

coderinthebox

The TechnoJunkie of the group who studied engineering but got stuck with software development. Remember kids, 90% of your problems can be solved by marketing. Solving the other 10% just requires good procrastination skills.

You may also like...

Leave a Reply

%d bloggers like this: