Brian2000

What to do when WordPress asks for connection info

A great feature in WordPress is automatic updating, it makes life easier for administrators and the feature is now integrated into everything from updating the core software to individual plugins and themes. A very common configuration problem that people run into with auto-updating is when Worpress prompts you with "To perform the requested action, connection information is required", and asks you for FTP credentials.

Have no fear, you do not have to manually update WordPress! There are a few ways of addressing this issue. The most obvious solution is by entering in your FTP credentials, however not everyone wants to enable FTP on their site, and there is a much better way of addressing this issue... Wordpress: connection information is required

First: Why is this happening?

In version 2.6 WordPress introduced the Filesystem API which governs all the functionality needed for reading and writing local files to the filesystem. The API supports most host types, and ensures that these procedures are done securely.

Security is likely why you are receiving the FTP prompt in the first place. WordPress checks to see whether or not it has permission to directly write to the filesystem. It also goes one step further and makes sure that if the files being written are under the same user account as the user account that owns the system. If this is determined to be false the FTP prompt is displayed as the next best solution. Given the scenario a lot of people might try to run Chmod (a unix script that allows you to adjust read/write permission on folders). Chmod is actually rather far from the solution, so don't try writing a bunch of 7's into the folder permissions! Opening up the folder's permissions is bad practice anyway, and WordPress isn't looking for you to "fix" things like that (no properly written application will). WordPress is actually requiring you to make sure that the user account running WordPress is the same account that owns the directory your site is operating in (the Apache user). To do this, you need to change the WordPress user not the existing user's permissions!

Solution: Change the WordPress user to the Apache user

It's really easy to set the WordPress user account to the Apache account, the whole process is two quick steps. Step 1. Determine which account the Apache user is. To do this make a test php file with the following code:

 <?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>

Run this code from the WordPress folder and you'll be shown the Apache user account's name.

Step 2. Run the following Unix command on the WordPress directory to assign it's owner as Apache's user:

# chown -R root: wordpress

In the example above, the Apache user name (taken from step 1) is "root", and the target directory is named "wordpress". If you are the server administrator, for security purposes I don't recommend running Apache under the root account or naming the WordPress folder "wordpress". However for the sake of an easy-to-follow example I wrote the code as such.

If you are using Webmin, open up the File Manager and navigate to the WordPress installation. Click on info and change the user name under ownership to Apache's user. Make sure this applies to this directory and all subdirectories and you're set!

Webmin: change folder ownership

I told you these were two very easy steps! Now you should be able to automatically update your WordPress installation, and you have the peace of mind knowing your WordPress filesystem is properly configured!