IMPORTANT: Although WordPress.org claims the following on Giving WordPress Its Own Directory:
Many people want WordPress to power their site’s root (e.g.http://example.com) but they don’t want all of the WordPress files cluttering up their root directory. WordPress allows you to install it into a subdirectory, but have your blog exist in the site root.
As of Version 3.5, Multisite users may use all of the functionality listed below. If you are running a version of WordPress older then 3.5, please update before installing a Multisite WordPress install on a subdirectory.
But be careful, it is a trap. In most of the case, you will be setting up Multisite network for different domains, right? Read on, in Before You Create A Network:
You cannot choose Sub-domain Install (for a domain-based network) in the following cases:
- The WordPress URL contains a path, not just a domain. (That is, WordPress is not installed in a document root, or you are not using the URL of that document root.)
So, don’t be a fool like me, setting up the whole thing with WordPress in a subdirectory then found the Multisite’s Network Admin panel link cannot resolve to the current path. (All the single WordPress dashboard links point to the subdirectory correctly, but all the network dashboard links point to the root. I tried to change the PATH_CURRENT_SITE in the
wp_config.php but the browser gives me a
too many redirects error. Anyone knows how to solve that? I suspect that it has something to do with Permalinks and/or the .htaccess file, but didn’t figure out.)
Here is a walk through with a WordPress on its own root directory (with my add-ons to the official tutorial):
1. Setup the single WordPress (ref to my post Setup a wordpress multisite network on AWS EC2 (2)).
2. First deactivate all the plugins, then allow Multisite: Open up
wp-config.php and add this line above the first line that begins with
/* Multisite */ define('WP_ALLOW_MULTISITE', true);
3. After refresh your browser, you should be able to see the “Network Setup” option under “Tools” menu. Follow the on screen instruction to install. Here I chose the Sub-domains type.
4. Then you need to modify the
.htaccess files. (If the
.htaccess file doesn’t exist, just create one at where the
wp-config.php locates, then copy & paste the code into it.)
The official tutorial has a line at this point:
In some cases you might also have to add Options FollowSymlinks at the start of the file.
Maybe that is the solution to the subdirectory problem I mentioned at the beginning. I will try this out another day.
5. After modifying the files, log in again with the link on the screen. You will find the Multisite panel appeared:
At the left of your WordPress toolbar, My Sites is now the second item. There, all your sites are listed, with handy fly-out menus, as well as a Network Admin menu item. Under Network Admin you can use the Dashboard item to go to the Network Dashboard screen.
6. Then you can start working on creating your own network.
At this point you will only be able to create subdomain type network, i.e., sub1.example.com and sub2.example.com.
If you want to use different domains, you need to install the WordPress MU Domain Mapping plugins.
Follow the installation instruction. You need to copy the
sunrise.php from the
wp-content/ and add
define( 'SUNRISE', 'on' ); to
wp-config.php near where you added
If everything works fine, in the
Network Admin Dashboard -> Settings, you will find
Domain Mapping. Set it up in the way fits your needs. I filled the IP address with my EC2’s Elastic IP.
Hu… now you can add new sites. The
Add New Site page might still only allow you to add subdomain type site. But after adding, you can edit the site and change the domain address to anything you want.
Configure your domain register DNS to point to your server IP. Configure the Apache Virtual Host setting to point the domain to the wordpress path. In my case:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/wordpress <Directory /var/www/wordpress> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ServerName ex1.org ServerAlias *.ex1.org ErrorLog logs/www.ex1.org-error_log CustomLog logs/www.ex1.org-access_log common </VirtualHost> <VirtualHost *:80> ServerAdmin email@example.com DocumentRoot /var/www/wordpress <Directory /var/www/wordpress> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ServerName ex2.com ServerAlias *.ex2.com ErrorLog logs/www.ex2.com-error_log CustomLog logs/www.ex2.com-access_log common </VirtualHost>
After restarting your httpd service, you should see both site alive.