APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS














(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



WordPress on Mac OS X Leopard


2009/01/11




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');
  add_action('publish_post','numly_publish_post');
  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());
                  $this->bail(sprintf(/*WP_I18N_DB_CONN_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


;


Click here to add your comments





Sun Jan 11 17:36:07 2009: Subject:   ScottCarpenter
http://www.movingtofreedom.org

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: Subject:   ScottCarpenter
http://www.movingtofreedom.org

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

http://www.movingtofreedom.org/2007/05/09/how-to-wordpress-on-ubuntu-gnu-linux/

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

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

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. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

book graphic Internet Income guide

My Hard Truths about Easy Money on the Internet will show you how to make money on the Internet!

 I sell and support
 Kerio Mail server




pavatar.jpg
More:
       - Blogging
       - MacOSX
       - WordPress


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress