When installing and running a plugin, WordPress may prompt for FTP connection information, stating “To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed.”
Access the shell of your server, switch to root or run your command as a user with proper permissions
Run the following command if your apache instance is running as user “apache”
chown -R apache:wordpress wp-includes wp-admin wp-content
This will give Apache ownership of the 3 directories listed
This occurs if the WordPress application is unable to access the file system directly, most commonly due to security of the site files. If WordPress does not have the necessary permissions to modify the files, you will be prompted for administrative credentials with proper rights.
WordPress installs plugins by running the /wp-admin/plugin-install.php script. In a Linux hosting scenario, the files being created or modified must be owned by the same user that owns the script being run, normally the user Apache is running as. What the script must do is write to the /wp-content/plugins directory.
There are several options to find the user running the website. One of these is to run: ps aux | grep -i http. Another option is to run the whoami command in php.
After performing the fix, you should receive the following after installing the plugin. This example shows plugin WordPress Importer: