Problem
Failed to connect to FTP server
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.
(Followed by a form for FTP username, password and protocol – FTP/SFTP)
Solution
Ubuntu
chown -Rf user.group /path/to/root
Apache/Centos
sudo chown -R apache.apache /path/to/root
Apache/Centos
sudo chown -R nginx:nginx /path/to/root
path/to/file
is the server root path for the public folder, on many systems this is var/www/
Sample