Have you ever got the message Connection Information and a form is prompting you to enter FTP information when doing updates, delete, install new themes or plugins?
I saw that message after move all my hosting files from default location to other place that allows my website running on VPS with lower permission to increase the security.
This problem is very easy to fix and stop WordPress Ask for FTP Credentials again but you will frustrating sometimes of trying to get it done if you don’t know the causing of this problem.

Stop & Fix WordPress Ask for FTP Credentials
Stop & Fix WordPress Ask for FTP Credentials

What is Causing of WordPress Asking for FTP details ?

When automatically upgrading, installing or updating a theme or plugin or the WordPress core, WordPress needs to make changes to the file system.

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 prompted to enter your FTP user account information.

And the causing of this problem is:

WordPress asks for your FTP credentials when it can’t access the files directly. This is usually caused by PHP running as the apache user (mod_php or CGI) rather than the user that owns your WordPress files.

What Can I Do To Stop and Fix WordPress Ask for FTP Credentials?

The easiest way to solve this problem is add the following FTP information to your wp-config.php

define('FS_METHOD', 'direct');
define('FTP_BASE', '/usr/home/username/public_html/my-site.example.com/wordpress/');
define('FTP_CONTENT_DIR', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/plugins/');
// define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub');
// define('FTP_PRIKEY', '/home/username/.ssh/id_rsa');
define('FTP_USER', 'my-ftp-username');
define('FTP_PASS', 'my-ftp-password');
define('FTP_HOST', 'ftp.my-site.example.com');
// define('FTP_SSL', false);

Problem Solved?

  • No! WordPress still asking me again with that stupid message!
  • Just wait, I haven’t installed FTP service on my server!

Moving on. If you answer me like that, you had or need the permission to control your server.
For this first method, it’s fixing your problem on 99.9% of shared hosting.
For the second method which can fix your problem in any case, we’re going to find out which user owns the web server and give that user ownership of your WordPress installation.

Looking for web server ownership process

After test and research on Internet in many times, I realised it’s the owner of the PHP process, not the web server software processes like Apache, Nginx, …
So try running ps aux | grep php to see which user owns the PHP process. Here is my case:

$ ps aux | grep php
root      1249  0.0  0.1 290648  5956 ?        Ss   Sep17   0:01 php-fpm: master process (/etc/php/php-fpm.conf)              
http      1278  0.0  1.0 374340 39492 ?        S    Sep17   0:21 php-fpm: pool www                                            
http      1279  0.0  1.1 374808 41460 ?        S    Sep17   0:12 php-fpm: pool www                                            
http      3934  0.0  1.0 374852 38048 ?        S    Sep17   0:17 php-fpm: pool www

It tells me that the PHP process is running under the user http.
So, a quick solution will be to issue this command and give user recursive ownership of the whole WordPress installation

$ sudo chown -hR http:http PATH_TO_YOUR_WORDPRESS_FOLDER

Replacing http with whatever user is yours.
Notes: If you are using Ubuntu. The default user and group of your PHP and Web Server software is www-data.

I really hope that helps someone, I spent ages being confused over this “feature”! If you have any more details or information, or if this works for you, then please add a comment below

The post Stop & Fix WordPress Ask for FTP Credentials Upgrade and Install New themes, plugins appeared first on NARGA.

Other posts you may like:

  1. How to FIX WordPress Posts Missed Schedule Problem
  2. 10+ Essential WordPress Plugins to Backing Up your Database
  3. How to make your theme support Jetpack’s Infinite Scroll feature