XHanch Studio Log in | Register | Cart

Forum

[How to] Stop/preve...
 
Notifications
Clear all

[How to] Stop/prevent WordPress from asking/requesting FTP connection information

1 Posts
1 Users
0 Likes
1,256 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

In WordPress, we can easily install/upload and upgrade plugins and themes and upgrade/update your WordPress. For some web servers, there is a common problem where you will get a "To perform the requested action, connection information is required" message when installing/uploading and upgrading plugins and theme sand upgrading/updating your WordPress. This happens because of filesystem ownership or permission issue. So, WordPress will ask you to enter FTP details so WordPress can executing the process.

Why does this happen? What is causing this?

Whenever you use the WordPress control panel to automatically install, upgrade, or delete plugins, WordPress must make changes to files on the filesystem. Before making any changes, WordPress first checks to see whether or not it has access to directly manipulate the file system. If WordPress does not have the necessary permissions to modify the filesystem directly, you will be asked for FTP credentials so that WordPress can try to do what it needs to via FTP.

In order to understand why WordPress can’t write to the filesystem, we need to take a look at some WordPress internals. The following code is from the get_filesystem_method() method in the wp-admin/includes/file.php file:

if( function_exists('getmyuid') && function_exists('fileowner') ){
    $temp_file = wp_tempnam();
    if ( getmyuid() == fileowner($temp_file) )
        $method = 'direct';
    unlink($temp_file);
}

This code creates a temporary file and confirms that the file just created is owned by the same user that owns the script currently being run. In the case of installing plugins, the script being run is wp-admin/plugin-install.php.

This may seem a little counter-intuitive, since the only thing WordPress really needs to be able to do is write to the wp-content/plugins directory.

How to stop this?

Checking files and directories/folders ownership and permission

In order to fix this issue, you will need to make sure that the scripts which need to write to the filesystem are owned by the same user that apache is running as.

Many hosting companies will run your apache instance using your user account, and all of your files will be owned by the same account. In those cases, you will probably not have the issue described here.

If your hosting company is running apache as a system user, and your files are owned by your own account, your only option may be to enter your FTP credentials here and allow WordPress to use FTP.

If you are running on a hosting company that gives you root access, or you have installed WordPress on your own development machine at home or at work, you should be able to modify the filesystem permissions to allow WordPress to directly access the filesystem.

The easiest way to do this is to find out what user apache is running as and change ownership of the entire WordPress directory to that user. For example, if apache is running as httpd, you could use the following commands on your WordPress installation directory:

chown -R httpd: wordpress

Note that not all versions of chown are equal. If that command does not work, see your local chown man page for usage information

In order to find out what user your instance of apache is running as, create a test script with the following content:

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

If still you are facing issue then give 777 permission to all wp-content folder.
For permission use following command

sudo chmod -R 755 path-to-public-html/wp-content

Define your FTP details in wp-config

You need to add the following code in your wp-config.php file:

define('FTP_USER', 'ftp-user');
define('FTP_PASS', 'ftp-pass');
define('FTP_HOST', 'localhost');
define('FTP_SSL', false);
 
Posted : 23/08/2012 11:02 pm
Share:

× Close Menu