I had the same experiences for several times with Apache configuration and I thought that caused from configuration file or permission, but I could not find and fix it properly. I tried to change permission of my root project folder. I raise up a case where I can not upload plugin/theme or update those modules, but it required to input FTP credential in my localhost. I tried to change permissions in wp-content folder for uploading new plugings or giving permission to wp-admin & wp-include, but everything was completely wrong.
Finally I founder that /var/www is belongs to current User Account. After add current user account to www-data user group, then I changed ownership of /var/www to www-data user group. Finally, I gave group permission to read & write in web server root. Every problem that happened before was solved successfully. You can find the command line below.
sudo adduser $USER www-data sudo chown -R www-data:www-data /var/www sudo chmod -R g+rw /var/www