I am trying to update my wordpress site plugins and themes but I am not able to update them. I am getting below message.
An error occurred while updating All In One WP Security: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions. languages, wp-security.php..... so on errors of plugins updates.
What I have tried is
set permission of file and folders by the following commands
find /var/www/html/ -type d -exec chmod 755 {} \;
find /var/www/html/ -type f -exec chmod 644 {} \;
chmod -R 777 /var/www/html//wp-content/cache/autoptimize
run below code for setting permissions
function AllDirChmod( $dir = "./", $dirModes = 0755, $fileModes = 0644 ){
$d = new RecursiveDirectoryIterator( $dir );
foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
if( $path->isDir() ) chmod( $path, $dirModes );
else if( is_file( $path ) ) chmod( $path, $fileModes );
}
}
added below code in wp-config file because wp asking for FTP details when installing or updating anything.
define('FS_METHOD', 'direct');
My site is on AWS EC2 Ubuntu 16.04 with php7 server.
You might need to make your web server as the owner of your project directory. Use the following command if you are using apache:
sudo chown -R apache:apache /var/www/html/