Localhost WordPress site asking for FTP credentials on installing new plugin

In one of the WordPress projects we are working on, whenever we tried to install a new plugin in locally installed WordPress, it asked for FTP credentials:

When we tried to install a new theme then also it asked for the same:

Actually, the problem was Apache web server was running on behalf of the www-data user on Ubuntu while WordPress folder and its files and subfolders were owned by a different user. So WordPress was not able to perform read/write operations inside WordPress folder:

ls -asl /var/www/html/wordpress
4 -rw-r--r-- 1 myuser myuser // myuser is username and myuser is group

So I changed the owner and group to www-data recursively like this which solved the problem:

sudo chown -R www-data:www-data wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *