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 root@127.0.0.1 = 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.

27 Responses to “Leopard: How to Install WordPress”

  1. October 16, 2008 at 9:25 pm, Yost said:

    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.

    Reply

  2. November 11, 2008 at 1:10 pm, Dave said:

    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”.

    Reply

  3. January 08, 2009 at 2:20 am, tgp said:

    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

    Reply

  4. January 10, 2009 at 12:55 pm, Shams-143.priya said:

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

    Reply

  5. February 04, 2009 at 2:53 am, anonymous said:

    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

    Reply

  6. February 05, 2009 at 10:24 am, Fábio Morbec said:

    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

    Reply

    • February 05, 2009 at 10:25 am, Fábio Morbec said:

      ops, the third line is:

      cd /etc/

      and not cp /etc

      Reply

  7. February 11, 2009 at 2:24 am, sam said:

    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?

    Reply

    • February 11, 2009 at 2:50 am, sam said:

      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

      Reply

  8. February 16, 2009 at 4:15 pm, Guest said:

    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

    Reply

  9. February 18, 2009 at 2:25 pm, Todd Wheeler said:

    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.

    Reply

  10. February 20, 2009 at 9:52 am, Phillip Gibb said:

    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)

    Reply

  11. April 04, 2009 at 6:41 pm, John Schuster said:

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

    Reply

  12. May 10, 2009 at 5:51 pm, Bill Durbin said:

    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

    Reply

  13. June 13, 2009 at 2:12 am, Vadim said:

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

    Reply

  14. June 22, 2009 at 8:38 pm, Tjerk Zweers said:

    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.

    Reply

    • June 24, 2009 at 1:11 am, Anonymous said:

      No problem! Thanks for the startup hint.

      Reply

  15. August 21, 2009 at 12:32 am, Anonymous said:

    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.

    Reply

  16. September 07, 2009 at 4:35 pm, tung desem said:

    Thanks for the tutorial , i like it.

    Great…

    Reply

  17. October 01, 2009 at 4:23 pm, Anonymous said:

    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’);

    Reply

  18. November 17, 2009 at 2:36 am, Anonymous said:

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

    Reply

  19. February 07, 2010 at 10:11 pm, Joe R said:

    You gotta be kidding

    Reply

  20. March 24, 2010 at 11:32 am, Anonymous said:

    mmm…interesting, thanks

    Reply

  21. April 11, 2010 at 4:06 am, Dennis Wurster said:

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

    Reply

  22. October 22, 2010 at 8:14 am, Vitaliy Syromyatnikov said:

    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 :)

    Reply

  23. December 07, 2010 at 1:57 pm, Coopérative Quinode said:

    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

    Reply

  24. January 06, 2011 at 7:17 pm, Short Break Portugal said:

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

    Reply

Leave a Reply