(dv):Setup WordPress network with subdomains
- This page was last modified on December 29, 2011, at 05:25.
From (mt) Community Wiki
Contents |
Overview
This article will outline the steps necessary to install a WordPress Network (multisite) instance on your (dv) Dedicated-Virtual. The assumption will be that the Network is being configured to use subdomains, rather than subdirectories.
Details
In order for a WordPress Network to function, the following must hold true:
- The DNS records for your domain(s) and subdomain(s) which will be hosting sites on your WordPress Network must resolve to the IP address the sites will operate from on your (dv) Dedicated-Virtual. This can be done with 'A' records pointing to the IP address, or with 'CNAME' records pointing to a different domain name which will resolve to this IP address. This configuration needs to be made at the nameservers which are listed as authoritative for the domain(s) in question. Most likely, you will want to create a wildcard subdomain 'A' record pointing to this IP address so that any subdomains tried will resolve correctly and you won't need to modify your DNS zone ffile each time you add a new site to your WordPress Network. If you do not run private nameservers on your (dv) Dedicated-Virtual, it is best to switch off DNS services for each of your domains in Plesk.
- The Virtual Hosts configuration on your (dv) Dedicated-Virtual must be configured so that these subdomains or domains will be interpreted each as a ServerAlias of the main site in the WordPress Network. This way, it will be entirely up to the WordPress software to decide what content to display for each different subdomain or domain. This can be really simple if you use the "Default Site Method" below.
- The WordPress software itself must be properly configured to enable the Network functionality. If you wish to use multiple domains for the sites instead of just subdomains, a domain mapping plugin will also need to be installed and properly configured.
Instructions
These instructions are broken down into two methods. The first method is much simpler to set up and will automatically be compatible with domain mapping, without the need to configure each mapped domain in Plesk. The second method requires more customization on your (dv) Dedicated-Virtual, but will be necessary if you need to run multiple WordPress Networks on the same IP address or if you cannot make the WordPress Network the default site for your IP address.
Additional IP addresses are not necessary to install WordPress Networks on a (dv) Dedicated-Virtual and (mt) Media Temple is not known to provide additional IP addresses if a WordPress Network installation is the only reason for the additional IP address.
Default Site Method
If you make your WordPress Network domain the default site for its IP address in Plesk, requests for pages on any domains or subdomains will automatically fall under the ServerAlias for your WordPress Network domain, unless the particular domain or subdomain has otherwise been explicitly added and configured with hosting in Plesk.
- Make sure that the DNS records for your domains and subdomains are properly configured so that they will resolve to the IP address you are hosting the WordPress Network on. If your domain uses (mt) Media Temple nameservers, check the "How can I change the DNS records for a domain I registered/host with (mt) Media Temple?" article for information on editing your domain's DNS zone file.
- Add the main domain of your WordPress Network in Plesk.
- Make this the default site for its IP address in Plesk. This will not affect other sites you have configured in Plesk, since it only applies to web site requests for sites which do not have hosting enabled in Plesk. For information on changing the default site for an IP address, please see the "How do I set the default site for an IP address?" article.
- Install WordPress on that domain. For manual installation instructions, please check the official "Installing WordPress" article. If you have a (dv) Dedicated-Virtual 4.0, instructions on installing WordPress through the Application Vault in Plesk can be found in the "Using Application Vault" article. Once installed, I recommend making sure you are running the latest version: Updating WordPress
- Follow the instructions in the official "Create a Network" documentation to initialize the multisite functionality in WordPress. Since you have already configured your DNS records and the 'wildcard' ServerAlias functionality is gained for free by having the site set as default for the IP address, you should skip directly to "Step 3: Allow Multisite".
- If you would like to enable domain mapping, please consult the "Multisite Domain Mapping Tutorial" for information on installing and configuring the "WordPress MU Domain Mapping" plugin.
With the "Default Site" method, the Webmail service, if turned on in Plesk, will continue to function.
Wildcard ServerAlias Method
If you cannot make the WordPress Network the default domain for its IP address, you will need to create your own ServerAlias configurations.
1. Log into your AccountCenter.
2. From your (dv) Control Panel, edit the DNS Zone file of the domain that will be hosting your WordPress Network. You should have an A Record *.yourdomain.com. If not, add the A Record and the data field contains your IP Address.
3. While still in your (dv) Control Panel, under "Manage this Server", "Root Access & Developer Tools" you'll need to enable "Root Access". It will request a password to be set. For more information, read this article: (dv):Enable root access.
4. Log into your Plesk Control Panel and navigate to the domain to host the WordPress Network. Under "Services", "DNS Settings", check to see if you have an wildcard subdomain *.yourdomain.com. If not, add the A record with the same information as Step 1.
5. Connect to your (dv) via SSH. For more information, read this article: (dv):SSH connection.
6. Once logged in, you'll need so switch to your root user:
type: su root and press enter, you'll be prompted with your root user password (which you established in Step 2). Enter your root user password and press enter.
You will now see [root@yourhostingdomain yourdomain.com]# in the terminal window.
7. Edit or create your "vhost.conf" file. To do so, type: cd /var/www/vhosts/yourdomain.com/conf and press enter. Then type: vi vhost.conf and press enter again.
To go into insert mode type: i
If your vhost.conf file is empty, type the following
ServerAlias *.domain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com
RewriteCond /var/www/vhosts/domain.com/httpdocs/%1 -d
RewriteRule ^(.*) /%1/$1 [L]
Substitute domain.com for your domain. Now here’s a quick walkthrough how these rules work. The first line ServerAlias *.domain.com tells apache to accept anysubdomain.domain.com.
If your vhost.conf file is not empty, make sure it contains the above lines and change ServerAlias www.domain.com to *.domain.com
Escape out of "Insert" mode, and save your vhost.conf changes by typing :wq and hitting enter.
8. Now you'll need to apply your vhost.conf changes. Enter the following command to do this on the (dv) Dedicated-Virtual Server 3.5 or older:
/usr/local/psa/admin/sbin/websrvmng -a -v
On newer versions of the (dv) Dedicated-Virtual Server, such as the (dv) Dedicated-Virtual Server 4.0, you'll need to enter this command instead:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
You should now be ready to host a WordPress Network with subdomains.
Notes/Supplemental
Additional WordPress help: http://codex.WordPress.org/Create_A_Network