Again, as is often quite a common occurence on my blog, i'm again blogging something that I think me and my team will find useful in the future. This time it's setting up a Wordpress MU installation on OS X using MAMP.
We needed a WordPress Multisite install locally so that we could test flexibly, privately, and securely throughout the development process for a new project. It's definitely worth the effort especially if you - like us love developing locally.
Things you'll need
- Editor - vim, nano, mate
- MAMP installed
First lets create a site in /Applications/MAMP/htdocs/ - call it mutest
mkdir mutest cd mutest
Now checkout wordpress with your favourite version control (we use subversion).
svn co http://core.svn.wordpress.org/tags/3.3.2 .
You'll see it checking out wordpress now - when it's done navigate to localhost:8888/mutest/ and complete the Wordpress installation, i'm going to assume your competent with installing it normally.
Now open up the MAMP portal and perform the following.
Now go to Ports and change the default port from 8888 to 80 - once you do this mamp will restart and probably prompt you for your admin password.
We're going to use the subdomain mapping for wordpress rather than the subfolder so next we need to edit the /etc/hosts file (which is on your mac).
I use textmate with the terminal hook, so I fire up terminal and run a command like so.
You could run vim or any other terminal editor if you like.
Add two new example domains to the hosts file (you will probably add more in the future but two will do for now).
Save and exit.
Edit your Apache vhosts config file
Open /Applications/MAMP/conf/apache/httpd.conf in a text editor and scroll down to the line that says “#NameVirtualHost *”. Replace that line with the following code:
ServerName example.site.com ServerAlias example.site.com *.example.site.com DocumentRoot "/Applications/MAMP/htdocs/mutest" Options Indexes FollowSymLinks Includes AllowOverride All Order allow,deny Allow from all
Save and restart mamp server.
Configuring Wordpress MU
Wordpress Multisite is really easy to configure just start by adding the following to your wp-config.php file.
Once you've done this head to wp-admin backpanel and then look for the submenu 'Tools' and click Network.
On this page you will now see an option to use sub-domains for your site addresses. Make sure that’s selected, check the other details, and then click the “Install” button to make it happen. Note that you’ll see a warning message that says, “Wildcard DNS may not be configured correctly!” – we can ignore this warning because we know our DNS is correct.
Finally, complete the steps outlined there on the “Enabling the Network” page (i.e., create a blogs.dir folder and add the required code snippets to your .htaccess etc). After that, re-login to the Admin area and go to Network Admin > Sites > Add New to begin adding your sub-domain network sites.
Your done! It's all over. Your now rocking a nice little wordpress multisite setup locally. Good job. Grab a coffee and get coding!