WordPress Can’t Update Plugins
If your get the error while updating your wordpress installation or plugins: “To perform the requested action, WordPress needs to access your web server” and want to avoid using FTP method read below.
You can fix this issue by following steps.
At first check what user is running the wordpress. Create file named check.php and upload it to the root directory (where index.php is located). In the file check.php paste this code:
<?php echo(exec(“whoami”)); ?>
Then view this file in your browser. If it shows for example “testuser” and in the ftp manager you see all files are owned by ” apache” then you should change the permissions of all wordpress files to “testuser”
There are many ways to change permission, one way is to use Webmin File Manager (if you control the server), another is to use any ftp program or control panel provided by your hosting. Below is a screenshot of how to change Wordress file permissions in Webmin.
The problem is when you change file and folders ownership that way all permissions are duplicated and files inherit 755 permission from folder settings.
Correct wordpress files permissions are 644 for all files and 755 for all folders (few exceptions might be with uploads folder)
You probably don’t think we have to change all file permissions from 755 to 644 by hand? :)
Of course not. Head to the Command shell to execute few lines of code:
At first you have to navigate to the wordpress installation root directory, otherwise you might change entire servers’ permissions.
It is easier to open some FTP manager at the same time to look the correct path to wordpress intallation, typical steps would be:
- cd /home [Enter]
- cd yoursite_folder [Enter]
- cd public_html [Enter]
-
find . -type f -print0 | xargs -0 chmod 0664
Last command is most important, what it does is it searches all folders deep down public_html folder and change all file permissions to 644.
Don’t forget to delete check.php file you created in the beginning.
I know it can look difficult at first, so if you have questions, you can ask them below in comment section.