APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

WordPress on Mac OS X Leopard

© May 2019 Anthony Lawrence

For some time now I've had in the back of my mind that I ought to learn something about WordPress. It's not that I'd want to use it myself, but a lot of other folks do use it so it could be smart to know something about it. This was brought to the front of my mind by a recent comment at my post about Numly tags. Basically somebody has a WordPress plugin that doesn't work and I volunteered to take a look at it.

So the person who left me the comment sent me the php code and I looked at it and at a quick glance it looked reasonable. The person trying to use it explained that the main problem seems to be timing:

The main problem was the Numly plugin is grabbing the WordPress permalink before the WordPress post is published, forcing you to go log in to the Numly site after the esn is generated and manually correct the link on every esn entry. The plugin needs to wait until after the published permalink is generated.

Well, it looks like that is its intent because it has this:

 * Register our intentions with WordPress.
if (isset($wp_version))  {
  add_action('admin_menu', 'numly_add_option_page');
  register_activation_hook(__file__, 'numly_install');
} // if (isset($wp_version))

Of course at this point I don't know beans about WordPress but I assume that "add_action('publish_post','numly_publish_post');" means "do my function as part of publishing the post". What I don't know is whether that means AFTER the post is published or just before and that could be the problem. I figured I had better install WordPress and learn a bit more about it and its plugins.

So I went to WordPress.org, found the right download, unpacked it and moved it into my OS X web hierarchy. I then looked at the Installing WordPress instructions and found that it needs MySQL.

Aaargh. I already had MySQL here, though I figured I had better update it just in case, but my disgust comes from just using databases for this to begin with. That's my initial reaction, of course: it's possible that WordPress has good reason to use a database even though so much of the time flat files would be better. But never mind: I went out and found the latest MySQL for OS X and installed that. I then created the wordpress database and a user for it per the instructions. I edited the WordPress wp-config.php file to give it the name of the database and all that and then tried running "wp-admin/install.php" from my browser.

Of course it failed and just listed the file because the OS X webserver ships with php unactivated. I found the httpd.conf file by running "apachectl -V | grep httpd.conf".

 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf

and did a "sudo vi /private/etc/apache2/httpd.conf" to uncomment the "LoadModule php5_module libexec/apache2/libphp5.so" line and stopped and restarted "Web Sharing" in the "Sharing" Preference Pane. So far so good, but when I tried accessing "wp-admin/install.php" I got an error:

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at localhost. This could mean your host's database server is down.

  • Are you sure you have the correct username and password?
  • Are you sure that you have typed the correct hostname?
  • Are you sure that the database server is running?

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

That's not very helpful. I knew I had the correct user name and password because I could connect to mysql at the command line with that user/password and use the database. So what's WP's issue?

Well, we can get it to tell us. A little Googling informed me that I could edit wp-includes/wp-db.php and add a "echo (mysql_error());" line. It belongs right here:

if (!$this->dbh) {
                  echo (mysql_error());
<h1>Error establishing a database connection</h1>

There seems to be other code in there for showing errors if WP_DEBUG is set, but I couldn't get that to work so I added that "echo" line and now saw the actual error:

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) 

That was easy enough to Google - apparently Apple changed the location tp /tmp in Leopard. You just put "mysql.default_socket = /tmp/mysql.sock" in /etc/php.ini and again restart the webserever to fix that.

Except that after that I still get an error:

Access denied for user 'apl'@'localhost' (using password: YES) 

Great.. I added "echo " n$dbuser $dbpassword";" below my other "echo" and saw that I had stupidly mistyped my password into "wp-config.php". I fixed that, and the install proceeded. A minute later I had a working WordPress system running on Mac OS X.

OK - now I have just a little bit to learn.


Tony Lawrence 2009-01-11 Rating: 4.0

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> WordPress on Mac OS X Leopard


Inexpensive and informative Apple related e-books:

Take Control of Apple Mail, Third Edition

Take Control of Preview

Take Control of iCloud, Fifth Edition

Are Your Bits Flipped?

Take control of Apple TV, Second Edition

More Articles by © Anthony Lawrence

Sun Jan 11 17:36:07 2009: 5138   ScottCarpenter

I like MySQL for WordPress and think it's a good place to use a DB. I'm using an older version of WP along with the WP-Cache plugin which caches flat file pages for performance. I guess this still uses PHP though, and I've read where the newer versions of WP have a built-in cache that removes PHP from serving the cached pages altogether. (It grew out of WP-Cache.)

Sun Jan 11 17:38:11 2009: 5139   ScottCarpenter

Also: This is for GNU/Linux, but here's a write-up I did for installing WordPress:


May or may not be very useful for installing on OS X, but then, you should be using GNU/Linux anyway, right? :-)


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

A learning experience is one of those things that say, "You know that thing you just did? Don't do that." (Douglas Adams)

Linux posts

Troubleshooting posts

This post tagged:




Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode