Setting up a WordPress 3 Network (nee Multisite) on MAMP

I happened upon an interesting problem today whilst setting up WordPress 3.3.2 on MAMP. Essentially WordPress plays nicely with MAMP so long as you don’t want to switch on the Network feature that has been rolled in to the WordPress core since version 3.0 (it was previously available as WordPress MU (Multi User).

The problem is a result of WordPress Network’s inability to handle a host name with a specified port number. By default, MAMP uses port 8888 and 8889 for Apache and MySQL respectively, resulting in the host name http://localhost:8888 which WordPress Network won’t accept (the setup discussed here fails when using a host name that has a port number appended to it). However, with a few simple config changes to MAMP and and some very minor tinkering on the command line, you can overcome this problem.

Here’s how I got round the problem and got my WordPress Network working nicely on my local Mac. For the record, I’m using OS X 10.6.8 and MAMP version which includes PHP version and MySQL version. It’s also worth noting that, as far as my research could see, it is impossible to setup WordPress network in its sub-domain configuration on MAMP so the only option is to set it up in its sub-directory configuration. This wasn’t an issue for me as I need just this type of configuration.

Switch off OS X’s built in Apache web server.

Head in to System Prefs and make sure that Web Sharing is switched off. Otherwise OS X’s built in Apache server will get in the way of MAMP’s.

Download and install MAMP

No need for the Pro version, just the regular version of MAMP is all you’ll need. More info and download link here.

Configure MAMP

Firstly, set MAMP’s Apache document root to the proposed root of your local WP install. This is likely to be something like this:

/Users/mymacusername/Sites/mydomain/wordpress

Now set MAMP’s Apache and MySQL ports to web server defaults (80 and 3306 respectively). This will cause MAMP to request your OS X admin password whenever you start your MAMP server but if you’re savvy enough to be setting up a local web server, you can probably be trusted with an OS X administrator account!

Configure MAMP using its Preferences options

Edit your hosts file

Open a Terminal window and type:

sudo vi /etc/hosts

This opens the hosts config file in the vi text editor. At the bottom of the file, you’ll need to add the following line:

127.0.0.1 domainalias.co.uk (choose whatever you want for domainalias.co.uk, I used imagespa.co.uk)

Add an entry to your hosts file using OS X's Terminal

This basically means that from now on when you type domainalias.co.uk in to your browser it will actually point to the IP address of your local computer – the localhost.

If you’re unsure of how to use vi, take a look at this very helpful guide.

Restart MAMP

If the MAMP servers are still running, stop them and then quit the application. Ensure that the changes you made to /etc/hosts have been saved and exit your Terminal session. Probably best to restart your browser now as well. If you’re happy to do so, you might also do well to clear the browser cache as well. You can now restart MAMP and your browser. To check that everything is working as expected, create a really basic HTML file and save it in the folder that you specified as MAMP’s Apache root. Save the file as something like test.html and then visit http://mydomainalias.co.uk/test.html in your browser. If everything is ok, the file should render correctly and the host name in your browser address bar shouldn’t append a port number and certainly shouldn’t revert to localhost

Install WordPress

You can now download and install WordPress as normal using mynewdomainalias.co.uk as the WordPress Address (URL) and Site Address (URL) fields within WP’s ‘Settings’ menu. You can create the WordPress database using MAMP’s built-in version of phpMyAdmin. You’ll find full instructions for setting up WordPress locally on MAMP here. Don’t forget that just like our test.html file, WordPress needs to be installed in the folder that you specified when you configured MAMP.

Setup WordPress Network

You should now have a WordPress 3 install working nicely available at http://mydomainalias.co.uk with the WordPress admin available at http://mydomainalias.co.uk/wp-admin

You can now continue with the WordPress Network setup using the Codex instructions found here.

One comment

  • June 3, 2012 - 12:53 am | Permalink

    I used to use the default install of PHP/MySQL/Apache on OSx, but the problem is that being a developer I can’t be bothered setting it up and then having to research any problems that are encountered. I use MAMP Pro now, which is great as it has everything I need in one place for my Virtual Hosts, PHP Versions, PHPMyAdmin, dyndns & Postfix settings as well as other tools. I know it’s not hard to set up correctly, but I don’t want to have to go in and configure the web site by going into x files to amend the details. MAMP has the basics in one place and MAMP Pro has all the advanced parts in the same place too, like error logging and displaying, virtual host set up and such preferences. This is a great tool that is enjoyed by many front and back end web developers for the ease of use and setup. I know a few developers that are great back end developers but do not want to touch the inner workings of OS x. With MAMP/ MAMP Pro you can play around all you want & if you break it, you re-install it Simple :)

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>