Leopard: How to Install WordPress

Installing a local version of wordpress is one of the first things most designers and developers need to do. Leopard adds many new wrinkles to this task. These steps should get you up and running as painlessly as possible on OS X 10.5.


*Install the MySQL Database*

– Download and install OS X version of MySQL from here: http://mysql.org/downloads/mysql
– Install the MySQL package. You can install the preference pane by dragging MySQL.prefPane to /Library/PreferencePanes however, it is not very helpful as there is a bug that prevents MySQL from being started with this.

*Manually Start MySQL*

In one terminal window type:
sudo /usr/local/mysql/bin/safe_mysqld

Close that terminal window, and start another:

sudo mkdir /var/mysql/
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

You’ll need to manually restart mySQL using the above steps, every time you reboot your system.

*Configure MySQL*

– Add this line to your profile:

export PATH=”$PATH:/usr/local/mysql/bin”

If you need help with this, you can edit .profile with textedit using these directions.

– Next the user will need to complete configuration from terminal. You will need to substitute your chosen MySQL root password for {ROOTPASS} and the Bonjour computer name (shown at the top of Sharing in System Preferences) for {HOST}.


$ mysql -u root
> drop database test;
> delete from mysql.user where User = '';
> flush privileges;
> set password for root@localhost = password('{ROOTPASS}');
> set password for [email protected] = password('{ROOTPASS}');
> set password for 'root'@'{HOST}.local' = password('{ROOTPASS}');
> quit

*Create the WP MySQL Database and User*

– {ROOTPASS} will the same as the above. The example creates a database named wordpress and grants privileges to user wpuser and sets that user’s password to wppass. You can change these if you want but remember the values for when you install wordpress below. I suggest just using these examples.


$ mysql -u root -p
Enter Password: {ROOTPASS}
> create database wordpress;
> grant all privileges on wordpress.* to wpuser@localhost identified by 'foo';
> set password for wpuser@localhost = old_password('wppass');
> quit

*Turn on PHP*
– Edit the following file: /etc/apache2/httpd.conf
– remove the “#” from the following line # LoadModule php5_module and save the file.
– If you have problems doing this, you want want to read the directions for using textedit as a superuser.

*Install WordPress*

– Download and extract wordpress from here: http://wordpress.org/latest.zip
– Copy the contents (not the actual folder) to your Sites folder under your user name. (example: /Users/davak/Sites/)
– In the Sites folder, open wp-config-sample.php with textedit (or vi or whatever) and save it as wp-config.php
– Change the following first lines of the document to point to your database. If you used the default values above, you can block replace this. If you changed the database name, username, or password, then you will need to update the code to match your choices.

define('DB_NAME', 'wordpress'); // The name of the database
define('DB_USER', 'wpuser'); // Your MySQL username
define('DB_PASSWORD', 'wppass'); // …and password
define('DB_HOST', 'localhost:/tmp/mysql.sock'); // 99% chance...

*Restart Apache*

From the terminal…
sudo apachectl restart

*Hit the WP Installation*

– Use your browser to navigate to your install. Replace “user” with your username…

http://localhost/~user/wp-admin/install.php

Here is mine, for example…

http://localhost/~davak/wp-admin/install.php

*May need to update virtual hosts*

If everything is not working correctly, you may want to update your virtual hosts with the following command. Remember to replace “user” with your personal username.

sudo cp /etc/httpd/users/user.conf /etc/apache2/users/user.conf

Here is my command, for example…

sudo cp /etc/httpd/users/davak.conf /etc/apache2/users/davak.conf

Then you will need to restart apache again.

sudo apachectl restart

Hit the page with your browser again.

*TroubleShooting and Credits*

You may have issues with permissions when trying to upload, import, etc. You can correct this by doing a chmod on your sites folder and subfolders.

From the terminal navigate to your sites folder and run something like the following…

chmod -R go+w *

This will grant group and others write permissions. If you need higher local security, then feel free to grant permissions by a more restrictive method.

This information was gathered from several sources. If you have problems or need additional information, I would reference my sources for this article. Please post additional recommendations and issues in the forum comments associated with this article.

http://www.angry-fly.com/index.cfm/2007/10/26/Fix-for-MySQL-on-Leopard
http://warker.com/2006/09/16/wordpress-os-x-install-tips/
http://remysharp.com/2007/10/27/lamp-in-leopard-osx-105-php5-and-apache-22/

 

About David Kirk

David Kirk is one of the original founders of tech-recipes and is currently serving as editor-in-chief. Not only has he been crafting tutorials for over ten years, but in his other life he also enjoys taking care of critically ill patients as an ICU physician.
View more articles by David Kirk

The Conversation

Follow the reactions below and share your own thoughts.

  • Yost

    Oh my gosh… you have no idea how grateful I am right now, I’ve been working on this for several days now being a total unix noob and this just helped me to get it working. Thanks so much. 1% was all I needed.

  • Dave

    Really clear and very helpful, thanks.

    Just one comment – when editing wp-config.php I found that setting DB_HOST to “localhost:/tmp/mysql.sock” didn’t work, I had to just use “localhost”.

  • tgp

    Absolutely fantastic tutorial. One change though. In the newer version of WP,
    /usr/local/mysql/bin/safe_mysqld

    is now

    /usr/local/mysql/bin/mysqld_safe

  • http://gadgetguild.com Shams-143.priya

    Amazing Site I like it. It Was Quite Interesting NiceWork I appreciate the information you provided Excellent post. Keep it up!
    Good day!

  • anonymous

    Simply marevelous. I am a novice to PHP/MYSQL/APACHE, and was able to follow this tutorial without a hitch. Thank you so much, keep up the good work :D

  • Fábio Morbec

    Hello ! Nice tutorial !!

    Instead of create a folder on /var/mysql you can:

    cp /etc
    sudo cp php.ini.default php.ini

    Then, edit the line that starts with mysql.default_socket to look like this

    mysql.default_socket = /tmp/mysql.sock

    • Fábio Morbec

      ops, the third line is:

      cd /etc/

      and not cp /etc

  • sam

    Got stuck on “Add this line to your profile:” ’cause I can’t find .profile
    Get message from Terminal: The file /Users/xxx/.profile does not exist.

    Any help?

    • sam

      well, i guess there’s more than one way to skin that cat. I went to:
      /etc/profile and checked the username as such,

      if [[ $USER = “test” ]]
      then
      export PATH=”$PATH:/usr/local/mysql/bin”
      fi

  • Guest

    So far this site has been great but I am fairly new to mysql and DB’s in general. When I got to the part where you have to complete the configuration from terminal I get command not found when I type in mysql -u root. Any ideas on what I am doing wrong or what I need to do to get this to work.

    Thanks

  • Todd Wheeler

    Entering “set password for ‘root’@’macmini.local’ = password(‘password’);” in the third “set password” instructions produces the following error:

    ERROR 1133 (42000): Can’t find any matching row in the user table

    I have tried some variations of the set password line, but no luck. Should I stop and then start Mysql, or is setting a password for this user necessary?

    Thank you for this very helpful tutorial.

  • http://synapticlight.com/ Phillip Gibb

    Thanks for the recipe – I plan to do this over the weekend in order to migrate my blog from WP hosted to self hosted :-)

    Phill(synapticlight)

  • John Schuster

    Thanks for this. I look forward to installing WordPress locally this week :)

  • Bill Durbin

    Hello,

    I got through the installation with no problem, but it won’t let me login to wordpress. When I look at the table in mysql, there is only one user ‘admin’. I can’t login as my own user and I can’t login as admin. Am I missing something? I used all the username and password settings exactly as in this tutorial. What am I doing wrong?

    Thanks,

    BD

  • Vadim

    Thanks for a great tutorial! You saved me many hours of troubleshooting!

  • Tjerk Zweers

    Thanks for this excellent instructions. I have now WP 2.8 running smoothly on my Mac Mini.

    When I downloaded the mysql-5.1.35-osx10.5-x86.dmg I noticed that it included a Startup app. Once installed, this app starts up automatic the MySQL server after a reboot and no manual action is needed anymore.

    • Anonymous

      No problem! Thanks for the startup hint.

  • Anonymous

    Hi, noob here. I startted to follow your tut and didnt get far. I had to create a .profile because there wasn’t one already. So I did “nano .profile” to create it. Then I added the export path. After leaving the .profile file, I cant find a way to get back in. but also not sure how to change from local host in the terimal to run commands for the next mysql step.

    many thanks.

  • tung desem

    Thanks for the tutorial , i like it.

    Great…

  • Anonymous

    For Snow Leopard users you need to use the “new” password format else you will get the “error establishing a database connection” and if you use echo(mysql_error()); before the html error output in wp-includes/wp-db.php (line 343 in version 2.8.4) it will say “mysqlnd cannot connect to MySQL 4.1+ using old authentication”.

    So instead of using:

    set password for wpuser@localhost = old_password(‘wppass’);

    Use:

    set password for wpuser@localhost = password(‘wppass’);

  • Anonymous

    Great post – I am a Mac OS X and managed to get things up and running on my new Mac using this article.

  • http://twitter.com/OurToughTImes Joe R

    You gotta be kidding

  • Anonymous

    mmm…interesting, thanks

  • http://twitter.com/wildeep Dennis Wurster

    Have any tips for setting up access to allow WordPress’s Auto-Update feature to work?

  • http://how-to-install-wordpress.com Vitaliy Syromyatnikov

    Very detailed info.
    I guess today it’s more comfortable and quick and very cheap to get your WordPress blog as pre-installed script with your domain name and hosting account literally in 10 minutes without a “headache” of creating databases, users and so on :)

  • Coopérative Quinode

    About the ‘new’ versus ‘old’ mysql password command :
    This is not only for 10.6 – after I upgraded a 10.5.8 stock php install with entropy’s one (to get the GD support) I had to do this too.So this is a PHP MySQL driver upgrade issue

  • Short Break Portugal

    It seems easy now but i still have nightmares about my first install of WordPress on my private LAMP server.