Sometimes, when you install & update a WordPress plugin, WordPress will only prompt you for your FTP connection if it cannot write to
1 | /wp-content |
directly. In this post, we’re writing about how to install & update WordPress plugins without FTP.
If your web server has write access to the necessary files, it will take care of the updates and installation automatically. This method does not require you to have FTP/SFTP or SSH access, but it does require your to have specific file permissions set up on your webserver.
It will try various methods in order, and fall back on FTP if Direct and SSH methods are unavailable.
Read: https://github.com/WordPress/WordPress/blob/4.2.2/wp-admin/includes/file.php#L912
WordPress will try to write a temporary file to your
1 | /wp-content |
directory. If this succeeds, it compares the ownership of the file with its own uid, and if there is a match it will allow you to use the ‘direct’ method of installing plugins, themes, or updates.
Now, if for some reasons, you do not want to rely on the automatic check for which filesystem method to use, you can define a constant,
1 | '<a href="https://tomiup.com/tag/fs_method/">FS_METHOD</a>' |
in your
1 | wp-config.php |
file, that is either
1 | 'direct', 'ssh', 'ftpext' or 'ftpsockets' |
and it will use that method. Keep in mind that if you set this to ‘direct’, but your web user (the username under which your web server runs) does not have proper write permissions, you will receive an error.
Solution to install & update WordPress plugins without FTP
If you do not want to (or you cannot) change permissions on wp-content so your web server has write permissions, then make the changes following the instruction:
- Edit wp-config.php
- Add the code below to the wp-config.php:
1 | <span class="pln">define</span><span class="pun">(</span><span class="str">'FS_METHOD'</span><span class="pun">,</span> <span class="str">'direct'</span><span class="pun">);</span> |
- Save & enjoy your install & updates WordPress plugins without ftp!
For more details, refer here.
Don’t hesitate to give the comments below if you have any questions 🙂