Install and Configure WordPress on Mac OS X Snow Leopard Step-By-Step

WordPress famously promises a “5-minute install”. If you’ve tried to install it on your local Mac, you might give up around minute 9.

This is a Step-By-Step guide to installing and configuring WordPress 3.1 on Mac OS X 10.6 (Snow Leopard).

Having a local WordPress installation will greatly speed up your development time. It’s definitely worth setting up — the problem is that I haven’t found a single resource that tells you how to do it. I intend to fix that.

This article assumes you’re starting from scratch. There are a number of steps to get everything just right. This may look like a long and daunting project, but you should be able to complete everything in under an hour.

Step 1: Download all the required software.

Download the latest build of WordPress (3.1 as of this writing).

Download MySQL for Snow Leopard.

Download MySQL Workbench (GUI Tool).

You’ll also need a text editor capable of opening hidden files. I use BBEdit. You can download a fully functional demo from Bare Bones Software.

Step 2: Extract WordPress

Copy the “wordpress” folder to your “Sites” folder. In my case the path is:

/Users/Milkman/Sites/

So, the full path to WordPress is:

/Users/Milkman/Sites/wordpress

Step 3: Edit WordPress Permissions

WordPress runs as user “_www” according to the rules in your httpd.conf (apache configuration) file. WordPress needs permission to modify some files during the installation process. It also needs permission to download and install plugins and updates, so it’s best to get the permissions correct now and save yourself some trouble later.

Open terminal and enter the following commands:

cd /Users/Milkman/Sites/
sudo chown -R _www wordpress
sudo chmod -R g+w wordpress

(Change the path on the first line to your Sites folder)

Step 4: Edit your httpd.conf file

Open the httpd.conf file located at

/etc/apache2/httpd.conf

(This is where BBEdit comes in handy, since the folder and file is hidden.)

At line 167 change the path of DocumentRoot to your wordpress folder

DocumentRoot “/Users/Milkman/Sites/wordpress”

At line 194 change the path of “Directory” to your wordpress folder

<Directory “/Users/Milkman/Sites/wordpress”>

Enable php by uncommenting Line 115

LoadModule php5_module libexec/apache2/libphp5.so

Save the file. You’ll be prompted for an administrator password.

IMPORTANT: You’ll need to restart Apache before the changes go into effect. Open System Preferences, Click on “Sharing” and toggle “Web Sharing” off and back on. This will reload your httpd.conf file.

Sharing

Step 5: Install MySQL

Run the MySQL installer package.

Run the MySQLStartupItem package. (This will ensure MySQL starts when you boot up.)

Install the MySQL.prefPane (This installs a System Preference Pane that allows you to start and stop MySQL.)

Install MySQL WorkBench (a Graphical User Interface for working with MySQL).

Step 6: Configure MySQL

(This is the longest step in the process. Just follow along!)

Open MySQL Workbench (which should now be in your “Applications” folder).

Step 6a: First, Create a new connection.

Click on the “New Connection” button.

New Connection

Name the connection “localhost”.

Leave everything else as default.

Click “OK”

Setup New Connection

Next, double click “localhost” to open a connection

localhost connection

Step 6b: Create a new schema.

Click the new Schema icon: New Schema

Name the new schema “wordpress”.

Close this tab to return to the main window.

Step 6c: Create a new server instance.

Under “Server Administration” create a new server instance.

New Server Instance

This will start a Setup Wizard that will walk you through the process of setting up the server instance. Leave all the default settings as they are.

As the wizard proceeds, you may get the error:

Checking command ‘ps xa | grep “/usr/local/mysql/bin/[m]ysqld”‘
Server detected as running
Check if /etc/my.cnf exists locally
Operation failed: File /etc/my.cnf doesn’t exist

Don’t be alarmed. Continue hitting “next”. MySQL will create the required my.cnf file.

Step 6d: Create a new database user for WordPress

It’s generally not wise to run anything as root. So let’s create a new user for WordPress:

Under “Server Administration” you should now see a new database server instance called “mysqld@localhost” (or similar). Double click this instance.

On the resulting screen, click on the “Accounts” tab.

Accounts

Click the “Add Account” button (bottom left).

Now, there are three tabs (“Login”, “Administrative Roles”, “Account Limits”). Under the “Login” tab, name the account “wpuser” and create a password (enter it twice).

New WordPress DB User

Type “127.0.0.1″ into the field labeled “Limit Connectivity to Hosts Matching:”. THIS IS IMPORTANT! If you don’t do this step you will get a connection error later when trying to install WordPress.

Under “Administrative Roles” check the box “DBA”.

Hit “Apply”.

Next click on the tab labeled “Schema Privileges” (Just above the three tabs “Login, Administrative Roles, Account Limits”).

Select the user “wpuser”

Click the “Add Entry…” button.

For host, leave “Any Host” selected.

For schema, choose “Selected Schema:” and pick the “wordpress” schema (the database schema you created in Step 6b).

New Schema Definition

Click “OK”

Next, select the account name, and click the “Select “ALL”" button, and then “Save Changes”.

Select All

Now, MySQL should be configured correctly and you’re ready to install WordPress!

Step 7: Installing WordPress (Finally!)

Okay, by now you’ve downloaded WordPress, copied the files to your “Sites” folder, modified the permissions, modified your httpd.conf file, installed MySQL and created a database and user for WordPress. Whew!

Now you’re ready for the fun part!

Point your browser to http://127.0.0.1/wp-admin/install.php

WordPress will now ask you for the following information:

Database Name: wordpress
User Name: wpuser
Password: ********
Database Host: 127.0.0.1
Table Prefix: wp_

By default, WordPress fills in the “Database Host” field with “localhost”. I’m not sure why, but this doesn’t work! (At least not in WordPress 3.0.) You’ll get a database connection error unless you use 127.0.0.1.

If your wordpress folder permissions are correct, the installer will be able to save the wp-config.php file. Next, all you have to do is enter few more details and you should be using wordpress in no time.

This entry was posted in Techno-babble, WordPress. Bookmark the permalink.

30 Responses to Install and Configure WordPress on Mac OS X Snow Leopard Step-By-Step

  1. Techism says:

    Great tip on the CHMOD and CHOWN enabling auto plugin install and updates. I’ve done it a dozen times and always forget that step.

  2. Josh says:

    Unable to connect to http://127.0.0.1/wp-admin/install.php :( Any thoughts?

  3. andrew says:

    Best write-up I have every read on the subject.

    I have been setting and trying to install worpress on a Mac OS X 10.6 server for over 40 hours, since I have never done such a thing I had to learn about DNS and a whole bunch of other stuff but, I was stuck and you got me unstuck.

    The only difference is that I did not have to install MySQL, I only had to activate it, which took me a little while to figure out, and I did not need to edit the httpd.conf file as it was already set up to be a sever.

    Keep posting stuff for us people that don’t know how to use Terminal.

    • Eric says:

      Hi,
      I have 10.6 server running and have tried the steps above, currently I have the MySQL and Web service running in Server Admin. How can get this to work??? I’m getting a Access Forbidden error, any step by step methods would be much appreciated.

      Thanks,

      Eric

  4. andrew says:

    Oh, and when I did the final activation, I typed in the URL of the web site and when I was asked for a database host I put in127.0.0.1. Heck that database host thing could have been what was stopping me in the first place and no one even mentioned that in the sites.

    The other sites also just said things like, “change the _www permisions” without explaining how.

    So you rock and I want anyone else who is going through was I went though to know how to set up WordPress on a Mac Server.

  5. pachi says:

    Completed Step 6. Stuck at STEP 7.
    On pointing the browser to http://127.0.0.1/wp-admin/install.php it prompted for Root login which i entered and white screen was displayed. Restarted Web Sharing and repeating STEP 7.. and the result is the same blank page. Any troubleshoot is highly appreciated.

    Thanks
    Pachi

  6. Michael says:

    I ran into some trouble with the latest MYSQL distribution where the preference panel gizmo wasn’t able to turn on the server… I would click the “Start MySQL Server” and nothing would happen. I even tried to manually start the server by executing the command “sudo /Library/StartupItems/MySQLCOM/MySQLCOM start”, but that didn’t work either (no processes showed up in the PS table).

    Luckily, the “readme” file in the distribution of MYSQL had some suggestions that helped:

    Start the server using the command “/usr/local/mysql/bin/mysql_safe” (see the file for more instructions)

    That got the server started, and following your instructions did the rest.

    Thanks for putting this together. It was a total life-saver!

  7. opas says:

    This is very helpful. I can follow the step, and it works perfectly.
    Very clear. Thanks for this.

  8. awilliams says:

    Thanks for the kind comments. I’m glad this guide is helping people. Sorry I haven’t written anything new for a while. More posts to follow soon.

    • Bill Crawford says:

      Very helpful, thanks!

      In your future posts – any chance you can give some guidance on how to setup multiple wordpress blogs? I’d like to have a personal blog to go with the professional one I set up using your instructions. I seem to be missing the steps using the MySQL Workench properly on setting up the additional database.

      Thanks again.

      Bill

  9. James says:

    Excellent Article!

    I would agree; this is the best article outlining this whole process.

    Thanks!

  10. Bali Rakhra says:

    @Josh : I had problems connecting with the wordpress url too. After many hours of frustration and installing XAMPP etc, re-configuring MySQL Workbench, and re applying my wordpress permission in Terminal, finally the browser automatically redirected me to :

    http://127.0.0.1/wordpress/wp-admin/install.php

    So I don’t know what I did different, but this url worked for me, when http://127.0.0.1/wp-admin/install.php failed.

    Hope that helps someone else

  11. Richie says:

    Hi,

    I’ve followed all the steps but keep getting the “The uploaded file could not be moved to /Users/username/Sites/wordpress/wp-content/uploads/2011/07.” error.

    I have tried editing the permissions several times now and keep getting the same error. If I “get info” on my wordpress folder it shows that the directory (all all sub directories) have read & write permission for _www.

    Im on a 64bit mac running OSX 10.6 and Im trying to use WP 3.2. Everything else seems to be working fine. I just cant get it to install my theme.

    Is there something else I can try to fix this?

    • awilliams says:

      Try changing the user that apache runs as. You’ll find this setting in your httpd.conf file. Search the file for “_www” and you’ll find the line to edit. If this is your local computer, you can change this user to your own uername. This method is not very secure, but I’ve heard it solves this problem.

  12. Pingback: 23rd World » Tips on Install of WordPress on Mac OSX

  13. Pingback: 23rd World » Tips on Install of WordPress on Mac OSX – wordpress hosts

  14. eisGeist says:

    Many thanks for this step-by-step tutorial, it worked like a charm!

    What changes should be done if WordPress should be installed in

    /Library/WebServer/Documents/

    I tried a couple of times but I always went stuck.

    All the best!

    — eG.

    • awilliams says:

      eisGeist,
      The permissions on the /Library/WebServer/Documents path are probably different, as I think this is a system directory. You might have to be root to change the permissions. Let us know if you find a solution.

  15. eisGeist says:

    I tried a couple of times but didn’t have it to work.

    I also created a symlink “Documents” in /Library/WebServer/ pointing to the wordpress install directory ~/Sites/ but all I get is a white page with the string “It works!”. Well… I am happy about that, but where’s wordpress? :-)

    Worst of all is that wordpress doesn’t work. I realized this before starting to mess with /Library/WebServer/Documents.

    So I guess the message is not due to the symlink but to the installation itself that doesn’t work anymore.
    As far as I can remember I didn’t do any change in the System configuration and for sure didn’t touch WordPress since last message.

    I went again through your tutorial to check all the tweaks and all are on place, but the same I get the laconic message “It works!”.
    I fear to have to delete all and start, but doing this would have any sense?
    Your advice?

    Many thanks in advance.

    — eG.

  16. Josef Herz says:

    Very helpful tutorial.

    I also encountered a problem where I could not execute any of the PHP files in the wordpress directory, like the “install.php”.

    Any browser reference to a .php file would lead to the browser downloading the .php script.

    I was able to track the problem to the .htaccess file that has the following:

    # Use PHP5 Single php.ini as default
    AddHandler application/x-httpd-php5s .php

    By commenting the second line and saving the the .htaccess file – solved the problem.
    The .htaccess file now looks like:

    # Use PHP5 Single php.ini as default
    # AddHandler application/x-httpd-php5s .php

    The “install.php” file executed properly.

    Thanks again for the tutorial.

    Josef

  17. Jeremy Jones says:

    Worked wonderfully! I’d been avoiding doing this for a long time as I couldn’t find a solid tutorial to walk me through it. Well done and many thanks :)

  18. Nik says:

    Hi, thanks for the tutorial. It’s all great and I got through most of it, however was stumped on Step 4 for the longest time. How do you edit in Apache?? Are we editing that in Terminal or in BBEdit and how exactly?

    • awilliams says:

      Nik, that’s where BBEdit or another text editor comes in. You’ll need an editor that can open hidden files.

      • Nik says:

        Actually I figured that. I have BBEdit open and am having trouble pulling up those lines 167, 194, etc.. to edit them. I’m a bit of a novice to this, can anyone walk me through this editing process using BBEdit?

        • awilliams says:

          If the file is locked, you’ll need an administrator password to unlock it. It will prompt you for a password once you try to save the file.

          • Nik says:

            Actually I am the administrator for this computer, but I’m not even at that stage of saving it… I can’t even open the file using BBEdit. How do you open it?

          • awilliams says:

            Choose File > Open Hidden… and browse to the httpd.conf file at /etc/apache2/httpd.conf

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>