Installing WordPress on Snow Leopard


WordPress is an excellent open-source bloging platform that's found mass appeal due to its powerful tools, ease of use and options for customization. Since it's based on PHP, a standard Web markup language, it can be hosted on nearly any Web server. While the WordPress organization offers free hosting on its own servers, many bloggers prefer to host it themselves so they can have full control over the code. When I decided to become one of the latter, I intended to host my WordPress installation on my Mac mini at home running OS X Snow Leopard. While I would have preferred to use Snow Leopard Server, the client version would work fine due to having a Web server, Apache, built into the OS. But actually installing WordPress became a bit of a scavenger hunt; I found no comprehensive, straightforward guide to getting it installed on a clean OS X install -- I found bits and pieces, mostly intended for Web developers, and had to figure it all out myself. This guide is intended to serve as a simple walkthrough for setting up a complete, working WordPress installation on Snow Leopard for those with minimal Web development experience. I've tried to use GUI tools whenever possible, but some tinkering with the command line is necessary. Don't worry though, you'll be told exactly where to go and what to type.

You may be a little confused at this point. If you've been thinking of installing WordPress on your Mac, you may have found some walkthroughs using MAMP. While MAMP certainly is a simple way to get WordPress up and running, I don't like it simply because it runs as an application, not as services. If you quit MAMP, your WordPress site goes down. If you log out of the computer, your WordPress site goes down. (You get the idea.) This walkthrough shows how to use services to run your WordPress site, which run independently of the current user's session. Your WordPress site will continue to run if no one's logged into the computer, which I view as a good thing not only for convenience, but also security.

To get started, you'll need to download three things:

1. MySQL for OS X, either the 32-bit or 64-bit DMG package. If your Mac only has a Core Solo or Core Duo processor, you'll want the 32-bit package; if your Mac has a Core 2 Duo or newer CPU, the 64-bit package is best.
2. Sequel Pro, a free database management frontend.
3. WordPress itself.

Now, open System Preferences and go to the Sharing pane. Click the checkbox next to Web Sharing to turn it on. If you have the built-in OS X firewall enabled, it will automatically add an exception for incoming Web traffic. If you aren't using the firewall, consider turning it on -- unless you plan on using your WordPress installation for internal testing only, exposing a computer, including an OS X machine, to the Internet without a firewall isn't the best idea. Don't rely on your router's built-in firewall to protect you completely.

You'll need to visit System Preferences again in a couple minutes, so simply push the window to the background or hide it for now.

While OS X's Web server is Apache (a common and popular Web server for Unix and Linux-based computers) and supports PHP, which WordPress is based on, PHP isn't enabled by default. Our first command-line task is to fix this. If you're not familiar with Unix command lines or using the Terminal is OS X, relax -- we're going to use an excellent and simple text editor built right into OS X.

Open the Terminal. It should take you to a prompt that looks ilke this:

BlackBook:~ drwebster$

In this example, BlackBook is the name of my black MacBook, and drwebster is my username. The dollar sign is the command prompt.

Enter the command sudo nano /etc/apache2/httpd.conf and press Enter. You'll be asked to enter your password; do so and press Enter. (For those curious, sudo means to run the command as the root user, which has access to everything. The file we're editing otherwise is locked for editing, so editing it as the root user is the easiest way.) The Apache config file should open in Nano, an easy and straightforward, if limited, text editor:


Notice the list of commands at the bottom of the window. Press Control-W (yes, the Control key, not the Command key -- remember that Unix was written back in the day before the Mac existed, and that is has multiplatform support) to bring up the search bar towards the bottom of the window.

In the Search: field, type in #LoadModule php5_module then hit Enter. It should take you to the line in the main body of the window; simply delete the pound sign (#) from the beginning of the line to activate it. Then, press Ctrl-X to exit, press Y to save the changes, and press the Enter key to keep the existing filename. You should be taken back to the command prompt in the Terminal window.

Next, we need to create and edit a key file that PHP uses. You'll need to stop and restart Web Sharing in the Sharing pane of System Preferences first; just uncheck the box, wait a second, then check it again.

Back in your Terminal window, enter the command cd /etc and press Enter. Now enter sudo cp php.ini.default php.ini and press Enter. This creates the file that PHP uses for its settings from a template file that's built into OS X. Now we need to edit the new file, so enter sudo nano php.ini and press Enter.

There are five lines in this file that we need to edit, and the process will be the same as when we edited the httpd.conf file earlier. Here's a step-by-step on what to edit, and what it should look like after you've made the changes. Be careful to make the changes exactly as listed, including the location of space characters.

1. Press Ctrl-W and search for ;date.timezone
2. Open a Web browser to and find the timezone that's closest to you. Being in Minneapolis, I chose America/Rainy_River as the closest match geographically. All that really matters is that you choose a location that's in the same time zone.
3. Back in Nano, remove the semicolon from the beginning of the line it found, and add the timezone to the end. After I edited the line, it looked like this for me: date.timezone =America/Rainy_River
4. Now we need to change where PHP will look for a MySQL file, since the default won't work for us. Press Ctrl-W and search for pdo_mysql.default_socket, and edit the line to look like this: pdo_mysql.default_socket=/tmp/mysql.sock
5. Search for mysql.default_socket and edit the line to look like this: mysql.default_socket=/tmp/mysql.sock
6. Search for mysqli.default_socket and edit the line to look like this: mysqli.default_socket=/tmp/mysql.sock
7. Now let's change the way Apache deals with short tags. Search for short_open_tag = Off, and edit the line to read short_open_tag = On
8. We're all done with command-line text editing! Press Ctrl-X to exit, press Y to save the changes, and press Enter to keep the filename.

Now, one last time, we'll need to restart Web Sharing for the changes to take effect. After that's done, it's time to install MySQL.

WordPress uses PHP for rendering its Web pages, but relies on a database to store content. MySQL is a free open-source database that works great with OS X (in fact, it comes preinstalled on OS X Server, it's that popular). There's no command-line magic to get it installed, simply run the main MySQL installer package from the disk image you downloaded. After it's installed, run the installer package for the startup item, and then install the preference pane. Just double-click the preference pane item to install it; the system will ask you if you want to install it only for the current user, or for all users. If you only have one user account set up on your Mac, it makes sense to only set it up for the current user; if you have multiple users and wish for the other accounts to have the ability to start and stop MySQL, then install it for everyone.

Once the preference pane has been installed, check the box to automatically start MySQL when the computer starts up, and then click the Start MySQL Server button.

MySQL, by default, is set up to be configured through the command line. That sucks, so let's use a GUI-based management frontend. Sequel Pro is an excellent, simple and free (notice a pattern here?) application for managing MySQL, and it will make our next steps much easier. To install it, just copy the application from the disk image to your Applications folder. Launch the app, and you'll see the login screen. Just enter for the Host, and root for the username. Leave all the other fields as is; just click Connect.

You should now see the main Sequel Pro screen:


Let's create a database for WordPress to store its content in. From the Select Database drop-down menu, select Add Database…


For the sake of simplicity, I named my database wordpress and left the encoding as Default.


Since this is going to be a database for a Web server, we need to think about security. MySQL ships with two user accounts, root and anonymous. The anonymous account is actually an account with no username, so it's shown simply as a blank field. What's kind of scary is that neither of these accounts have passwords by default, leaving your database vulnerable. We need to tighten our MySQL security, namely, by removing the anonymous account entirely (WordPress doesn't use it anyway) and setting a password for the root account.

Click on the Select Database drop-down and choose mysql. Scroll down through the left-hand pane, and select the users table, then click the Content button in the toolbar. See? Neither of the users have passwords:


Notice that there's actually five lines for usernames. This is because MySQL allows usernames to authenticate against different hostnames that ultimately tie back to the same instance of MySQL. In the example above, localhost, BlackBook.local and all refer to the same thing, the computer that MySQL is installed on. BlackBook.local, in this case, happens to be the name of the computer I'm working on; your computer name will look different.

It's time for a little more command-line, but this time it's pretty simple. Click the Query button in the toolbar; this is where you can run commands against MySQL and see their output. In the upper pane, enter the command SELECT Host, User FROM mysql.user; and click the Run All button. Type it exactly as written here, case and all; notice that the arguments (words) in the command change color as you type them. After you clicked Run All, the bottom pane should show the same five lines we were just looking at in the table:


Let's delete the anonymous user, since we don't need it. Delete the existing command in the top pane, then enter these commands on two lines, pressing Enter after the first line.

DROP USER ''@'localhost';
DROP USER ''@'BlackBook.local';

On the second line, remember that BlackBook.local is the name of my own machine; you'll need to substitute yours as it's shown in the bottom pane. Click Run All, and it will execute the query.


Just to make sure it actually removed the anonymous account, delete the commands from the top pane and let's run SELECT Host, User FROM mysql.user; again:


Cool, now there's only three lines instead of five, and they all show as being for the root account. We just need to change the root account password, and we'll be done messing with MySQL.

Clear the command from the top pane, and enter these on separate lines:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MySecurePassword');
SET PASSWORD FOR 'root'@'BlackBook.local' = PASSWORD('MySecurePassword');
SET PASSWORD FOR 'root'@'' = PASSWORD('MySecurePassword');

In the above, substitute the password of your choice for MySecurePassword. I'd suggest using something that has a mix of uppercase letters, lowercase letters, and numbers or symbols for the best security. Also remember to substitute your own machine name for BlackBook.local. Click Run All.


Click on the Content button in the toolbar and check out the user table now:


Check it out, there's stuff in the Password column now -- specifically, an MD5 hash of the password you entered. Your MySQL database is now much more secure than before.

That's it for configuring MySQL; go ahead and exit Sequel Pro. Now it's time to actually install WordPress and configure it.

Thankfully, this process really couldn't be much easier. Open your hard drive, and from the root of it navigate to Library/WebServer/Documents. This is the folder that Apache (a.k.a. Web Sharing) looks at for content to serve; it should have three files in it now. They're just the default placeholder files that OS X puts there; move them to another location for safekeeping. Open the wordpress folder that you downloaded and copy all of its content to the Library/WebServer/Documents folder (you can Option-drag them to copy instead of move).

When all of the files and folders have been copied, double-click the wp-config-sample.php file to open it with TextEdit. Click Open at the "This is a script downloaded from the Internet" warning. We only have four lines to change, all of them in the same section towards the top of the file:

define('DB_NAME', 'putyourdbnamehere');
define('DB_USER', 'usernamehere');
define('DB_PASSWORD', 'yourpasswordhere');
define('DB_HOST', 'localhost');

The parts to change are fairly obvious: putyourdbnamehere should be the same as what you named your WordPress database (in my case, wordpress); usernamehere should be root; yourpasswordhere should be your MySQL root password (MySecurePassword from our example). The only catch is that localhost must be changed to or WordPress won't find the database.


After you've made those changes, go to File --> Save As and save the file as wp-config.php in the same directory as the other WordPress files. Be sure to keep the .php file extension on the name when you save it, otherwise TextEdit will automatically add .txt instead (and that won't work for WordPress).

All you have left to do is one very simple task -- open a Web browser and navigate to http://localhost and see what you get:


Happy blogging!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Installing WordPress on Snow Leopard

Hi! Thanks for your tutorial. Best one I found!

Now that I've got WP set up on my mac mini, I'd like to be able access it from the internet. I don't expect much traffic, so I think my fiber-optic connection should be fast enough. I will use no-ip to get around the dynamic dns problem.

Do you have any tips or google search terms to suggest? I haven't been able to google up anything that helps me. (I'm not that savvy with this, that's why your tutorial was so welcome!)


Dr. Webster's picture

Re: Installing WordPress on Snow Leopard

homehoster wrote:

Hi! Thanks for your tutorial. Best one I found!

Now that I've got WP set up on my mac mini, I'd like to be able access it from the internet. I don't expect much traffic, so I think my fiber-optic connection should be fast enough. I will use no-ip to get around the dynamic dns problem.

Do you have any tips or google search terms to suggest? I haven't been able to google up anything that helps me. (I'm not that savvy with this, that's why your tutorial was so welcome!)


It's going to depend on your network router. You need to implement what's called "port forwarding." If you have an Apple AirPort router, here's a quick guide to set it up. Since you're serving a Web site, you'll want to forward TCP port 80.