How to fix WordPress Install/Update Plugin not working on a custom VPS
If you are running a VPS or a Server web by yourself, can happen that the auto-install or auto-update WordPress features are not working: WordPress shows you the message “Connection Information – 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.
And next ask you about your FTP credentials; even with your FTP or FTPS credentials the auto install it’s not working. Why? The reason it’s a user permission issue: the owner of your website folder it’s different from the user that is currently trying to modify the content of the files and folders in your WordPress installation. What? Yes that’s right: the user that is trying to do those edits it’s the webserver, in my case NGINX, but this could be applied to systems running Apache too.
How to fix the problem
The Web-server user
Usually the web server user name it’s called www-data so the first step it’s make sure this user exists:
cat /etc/passwd | grep www-data
and the result should look like:
www-data:x:33:33:www-data:/var/www:/bin/sh
This means you have a www-data.
The NGINX user
NGINX, as well as the Apache web-server has an user (usully www-data). So make sure that this is the user of your NGINX. This information it’s contained in the file nginx.conf under the /etc/nginx/ folder.
Run:
cat /etc/nginx/nginx.conf
In the first line of the result you will find something like: user www-data; If this is the case here’s the solution: change the owner of your website directory, with this command:
Change user
sudo chown -R www-data /home/<yourusername>/<yourwebsite>
just change the example path
/home/<yourusername>/<yourwebsite>
to your website actual path if you didn’t followed my previous how-to on NGINX configuration and LEMP Web-server configuration.