I was very happy to finally get my wordpress site up and running on a localhost environment. However, I soon came up against a rather annoying snag…
Whenever I tried to install a plugin (or a new theme for that matter) a dialogue screen would come up asking for FTP credentials:
Anyway.. it turns out there’s an extremely easy fix for this on your localhost environment.
You need to edit your wp-config.php file, which you will find in the top level of your wordpress installation directory:
What you need to add to the file is:
define('FS_METHOD', 'direct');
In my case, I decided to add it after the database entries, and included a comment to remind me what it does.
Finally, if you already have your wp-admin page open in your browser, make sure to refresh it.
Job done, you can now add themes and plugins to your heart’s content 🙂
All that remains is for me to add this as a “final step” in my step-by-step “wordpress localhost install” guide.
Possible errors:
If you get the error: “Installation failed, could not create directory” when you try to install a plugin, it means your permissions are not set correctly.
Assuming that you are running a localhost via apache2 on a WSL install… In the bash terminal (Win > type: “bash” > enter on WSL), enter the following:
sudo chmod 777 -R /var/www/<<yoursitefolder>>
While you’re there you might as well make sure there are no ownership issues as well:
sudo chown -R $USER:$USER /var/www/<<yoursitefolder>>
I’ve seen “www-data:www-data” used in many tutorials instead of “$USER:$USER” – if I understand things correctly, www-data will allow you to make changes to your site files via your internet browser, but will not enable you to do things like copying/deleting/pasting files/folders in your site folder within Windows. Assuming you are not logged in to terminal as root, the $USER value will do the trick for your normal windows user account.
Leave a Reply