WordPress and automated update

with No Comments

Currently, I am having a go at building some WordPress plugins. It is not yet the time to explain why and how and what. But in order to test them out without too much hassle I have installed a WordPress tester site on my localhost and I wanted to be able to use the automatic update function for plugins and such. In fact I expected to be able to do this without problems as it’s running on my own machine, right? Not so!

Instead when trying to delete my first plugin, in this new installation I stumbled across an obstacle I had met several times before but had not expected to meet here.

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Screen Shot 2013-02-05 at 11.51.27

!!!

But, I installed it on my own localhost. Why do I need to login with FTP? And of course regardless of which password I used it didn’t help!

When I had come across this message in the past it was always on external servers where I had ftp connection details I could enter – which worked. But this time I had to try and look around for another solution.

Google was my friend – and I came across this post by Chris Abernethy. He put me on to the fact that it may be caused by the ownership of the apache installation and the WordPress directory not being the same.  A quick way to check the Apache installation user is to create a test PHP script with the following content, and run it:

<?php echo(exec("whoami")); ?>

This will tell you what your Apache user is (e.g. httpd, www-data, www) and the solution may be to run chown on your WordPress directory. So how do I do that?

I open up my terminal and navigated to my WordPress folder:

cd //
cd Library/WebServer/Documents

Here I had to run a sudo script to get root user permission.

sudo chown httpd *
sudo chown httpd */*
sudo chown httpd */*/*

I continued to add /* until I got an error message, thus working my way down through the subfolders and changing the owner as I went along. Thanks fkoosna on the WordPress support forum.

So now I went back and tried to upload a plugin again and this time it worked. Yeah!

Thought I’d better write it down before I forgot what I did.