I’ve run through this process a few times now, so I thought I’d document my steps for anyone who’s interested in setting up the multi-user version of WordPress on their local box for testing purposes. The power of the multi-user version of WordPress is impressive, especially when combined with BBPress for forums, and the teetering-on-official-release BuddyPress for social aspects. Ready to dig in? Lets go.
The first thing you need to ensure prior to installing WordPress MU locally is that you have the underlying technologies installed. WordPress and WordPress MU run on LAMP, or in this case MAMP. There are all-in-one packages out there that install all three for you, and OS X does come with versions of Apache and PHP, but we want to learn how to get our hands dirty and be able to fix anything ourselves in times of crisis, right? So we need to make sure you’ve got Apache running, MySQL installed with a dedicated database setup, and PHP installed.
Turning on the Apache Web Server
First, we’ll tackle Apache. This sentence will probably take longer to write than it will for you to turn on Apache on your Mac. Go to System Preferences > Sharing > Web Sharing. Checking of the “Web Sharing” checkbox here toggles the Apache server. If you ever need to restart Apache, its as easy as coming in here, unchecking the “Web Sharing” checkbox, and checking it again. Cake.
On to MySQL. You’ll need to download the most recent version of MySQL, which can be found at the MySQL downloads page. Click “downloads” under the MySQL Community Server section. Scroll down to the “Mac OS X (package format)” link and click. Here is where you’ll have to ensure you download the proper package based on your Mac. I chose the 10.5 (x86) since I’m running an Intel MacBook Pro, which ias the x86 processor. After you determine which package suits your Mac, click the “pick a mirror” link, and if you’ve never downloaded anything from the MySQL site before, you’ll have to register quickly. Once you’ve registered and downloaded the dmg (named
mysql-5.1.31-osx10.5-x86.dmg in my case), you’re ready to run the installer.
Once you’ve opened the dmg, you’ll see two .pkg files we’ll be interested in. First, run the installer pkg file, which will walk you through a simple install. After the initial install you’ll want to launch MySQLStartupItem.pkg, which will ensure that MySQL starts each time you restart your Mac. You’ve now got MySQL installed on your Mac! Note the install location, as we’ll need that later on to create the database for WordPress MU. Mine installed at /usr/local/mysql/bin/mysql.
Another item worth mentioning is that working with MySQL, PHP and Apache requires you to have access to a lot of OS X’s hidden files. I recommend a great OS X app called FileXaminer, which I read about in MacWorld a while back. FileXaminer lets you browse all the hidden files in Finder, and chmod the permissions on files and folders directly from Finder, rather than the command line. Definitely a great solution for 10 bucks.
The final piece of our MAMP stack is PHP. PHP installation is fairly straightforward, and the best package online is located at Entropy’s PHP download page. There’s a box on this page titled “PHP 5 on Mac OS X 10.4, PPC and Intel”, and you can select the “PHP 5.2.4 for Apache 2” package. Its definitely worth reading through this page first, but most users will have the default setup of Apache, and won’t need to make any changes prior to running the install.
After running the entropy installer, you can run a test to make sure everything went well. Create a file titled test.php, and stick the following code in it:
<?php phpinfo() ?>. Put test.php in your /Sites folder (/Users/yourusername/Sites), and then open up http://10.0.1.2/~yourusername/test.php. The IP used in this example is found in System Preferences > Sharing > Web Sharing.
The phpinfo function is a great way to quickly check all the settings of your PHP install, so save this test file for reference in the future.
There’s one final tweak to PHP that’s really a best practice. You’ll want to navigate to your php.ini file, and open it in your favorite text editor. My php.ini is located at /private/etc/php.ini. Make a duplicate of this file (sometimes the original will be called php.ini.default, so make a dup called php.ini). Once you’ve opened the php.ini file, search for “register_globals = On”, and switch it to register_globals = Off”. Also, search for “magic_quotes_gpc = Off” and switch it to “magic_quotes_gpc = On”. In the php.ini file, all lines that start with a ; are commented out, so you’ll want to search for these two lines that are not commented out and then make the changes.
Save the changes in php.ini, then restart Apache in System Preferences. Then open your test.php file again, and look for the changes to make sure they were made.
Installing WordPress MU
Finally, its time for the money melon. Download the latest version of WordPress MU from the download page. Unzip the package and stick it in your /Sites directory, and rename (I chose “wpmu”). The first thing you’ll want to do before attempting to install WordPress MU is to open the README.txt file that is in the root directory of the unzipped WPMU package. You’ll want to read this carefully and cater the specific files you your specific install case, but they basically touch upon the php.ini file that we’ve already edited, and the httpd.conf file, which is Apache’s root config file. I found mine located at /private/etc/httpd.conf. You can find a better understanding of the Apache httpd.conf file, the directives contained within, and an explanation of the .htaccess files you can use to override the httpd.conf file in your local sites at the Apache web site. I found that after reading a few short pages here, that the Apache config file cascade is very similar to the cascade of CSS files and rules. Cool stuff.
Creating a MySQL database
Once you’ve read through the README.txt and made appropriate changes to your php.ini and httpd.conf files (and taken decent notes, hopefully), you’re ready for the install. Since you’ve already got the files unzipped in your /Sites directory, the next step of the install is creating the database. Open the Terminal application (Applications > Utilities > Terminal), and type the following command:
/usr/local/mysql/bin/mysql -u root -p
where the path matches the MySQL path I mentioned to remember earlier. The -u root tells MySQL that you want to login as “username root”, and the -p tells MySQL to prompt you for a password. If you’ve never logged into MySQL in terminal before, the username for root will either be root or blank. After you’ve successfully logged into MySQL, you’ll know as the command prompt will have changed to:
To create a database, type the following command:
CREATE DATABASE wpmu;
where wpmu is the name of the database. You can name the database whatever you’d like, but make sure to follow it with the semi-colon, and remember the name of your database.
While we’re in here, its probably a good idea to change your root username. Type the following command:
UPDATE mysql.user SET Password=PASSWORD(“new password”) WHERE User=”root”;
Replace the new password with your desired password. Once we’ve created the database, and updated the root MySQL user’s password (and noted both), we can exit MySQL by typing:
Running the WPMU Installer
You can now open the index.php from your wpmu folder in your web browser. It may tell you that you have to change the permissions on a few folders prior to running the install. If this occurs, it is extremely easy to modify the permissions using FileXaminer. The two folders you’ll have to mod are the root /wpmu folder and the /wp-content folder, changing the permissions on both from 755 to 777. After you’ve made these changes, refresh the index.php file, and enter the proper information.
Since WPMU doesn’t allow you to install at “localhost”, and you have to use “localhost.localdomain”, I had to make a change in my hosts file as well. The file is located in /private/etc/hosts, and I changed:
and resaved the file. Also note that I set the database location to “localhost.localdomain”. The other information on the install screen should be pretty simple; the database name and password we just created in MySQL. Once you’ve filled out the form, submit and you should be looking at a nice, fresh, local install of WPMU.
If you do get stuck, the WPMU Forums are a big help, as most likely users have run into your same problem. The steps above worked for me, but there may be variables with your certain configuration that you’ll need answered in the Forums.
Good luck, and happy WPMU’ing!
UPDATE 3/4/09: If you’d like to configure OS X Leopard to host multiple local WordPress instances, follow this great tutorial at O’Reilly. I’ve spent hours piecing together solutions from various articles, but this O’Reilly article sums it up great. Basically, I’ve now got WPMU running locally at test.wpmu.local, and WordPress running locally at test.wp.local. Apache’s Virtual Hosts are really powerful, and essential if you’re going to be working on multiple client websites that run on WordPress.