Cant Update plugins or theme (wordpress)

August 10, 2015 2.5k views
WordPress PHP LEMP

whenever i try to update any plugin that comes as bundled with my theme i cant update. it says

update failed 
cant remove previous/old data

or sometime it says cant delete "plugins folder name". same this happens when i try to update my theme from envato theme update plugin. my theme is purchased from envato.

but when i try to update any plugin which i downloaded separately, ex. yoast seo, it updates without any problem.

does anyone faced similar issue?

What im using is
Wordpress 4.2.4
Nginx 1.8
PHP 5.5

thanks in advance.

  • In the solution, user "fatorbinario" and group "www-data" were just examples. If you login via FTP with another username different than the one you gave permissions with those commands that's the problem.

    A better example would be:

    sudo chown -R YOURFTPUSER:www-data /var/www/html

    *And as I said before, always make a backup.

  • @fatorXb2
    I m using the same user for my site ftp, wordpress and everything else.

  • @fatorXb2
    can you tell me whats the default permission for /var/www/html

  • Normally is rwxr-x-r-x (755)

  • thanks @fatorXb2
    things happening to me is after giving the following command as u described, i cant upload or change file permission for any folder using my non-root user.
    sudo chown -R YOURFTPUSER:www-data /var/www/html

    how can i give my non-root user full privilege as root again?

  • @fatorXb2
    thanks a lot.

    can you tell me how can i set permission for all folders to 755 and all files to 644 inside directory /var/www/html

    i dont want to do that manually each by each.

3 Answers

Thats about permission.

First define this on your wp-config.php and see if it solves:
define('FS_METHOD', 'direct');

If not you have to take ownership of the whole site directory.
Let's suppose your install is on /var/www/html and your site user operator is fatorbinario so you can type these:

sudo chown -R fatorbinario:www-data /var/www/html
sudo chmod -R g+w /var/www/html
sudo find /var/www/html -type d -exec chmod g+s {} +

*Make a backup first.

  • thanks @fatorXb2
    it worked. :)

  • Hi @fatorXb2

    your above solution solved my previous problem, thanks for that.

    but after running those commands now im having a problem with my ftp uploader(filezilla). now i cant upload any file with overwrite. if i try i get this msg

    Error:  /var/www/html/wp-content/themes/filename.php: open for write: permission denied
    Error:  File transfer failed

    so i had to edit from putty. but filezilla was working without any problem before. i think something changed after setting the permission parameter.

A few possible causes of this type of error are 1) incorrect ownership or permissions on the wp-content directory or its contents, and 2) running out of disk space. There certainly could be other causes. So, check permissions and disk space first to see if either of those are the cause of the problem.

  • Hi @jsamuel

    thanks for your quick response.

    File permission for wp-content is set to 755. also same for directories inside. once i thought i should change them all to 777 but is it safe? please advice me.

    i got another space(nearly 15GB) free for my droplet.

  • Hi @newbie

    It's generally not a good idea to change permissions to 777. The right approach is instead to make sure that the user your PHP scripts run as is also the user that owns the files and directories. That way, the 755 permissions on a directory are all PHP needs to write files there (the first number there is the permission of the owner, where "7" means all permissions including write permission).

    Sometimes the ownership of files and directories can be different from the user PHP runs as if you uploaded files as a different user than PHP runs as. If that's the case, you should try to remember to fix file ownership after you upload any file to your server.

Have another answer? Share your knowledge.