Plugins download & install fine, wordpress update fails

I've setup all permissions and directories/files correctly according to Wordpress. Adding plugins/installing/updating works perfectly, but when it comes to updating to 4.7.2, it asks me for FTP details or if I force FileSystem (direct) in the WP config file, it says it couldn't update due to inconsistent file permissions or not being able to create the directory.

Literally all file permissions and user permissions are setup as per the recommondation from wordpress, however I can't update the core.

The log file does say permission denied on line 257 of the filesystem include when it tries to copy a file, but like I said, correct permissions have been given unless, for that specific instance, the core update is run under a different user than apache?

Manual install is not being considered as the process needs to be seamless for operations to be able to support without requiring additional knowledge of FTP/SSH.

Can anyone recommend a solution that actually works?

1) I have chown to my apache user (this is required for the plugins to be updated) 2) all permissions are 755/644 (this is required for the plugins to be updated as well) 3) OS was updated including openssl (Redhat Enterprise)

Topic core automatic-updates updates Wordpress

Category Web


Disable FTP popup from everywhere in the Wordpress, simply add following line in wp-config.php file

define('FS_METHOD', 'direct');


I have seen this 'issue' with Centos.

Often ppl assume the user has used wrong permission settings for folders(755) and/or files(644), or owner settings (apache:apache).
But with Centos(7) it can be a security 'issue' orchestrated by SELinux.

Maybe following helps some ppl to solve this nasty problem.

  • OS: Centos 7
    Go in a terminal (use ssh access!) and type following:
    chcon -R -t httpd_sys_content_t /var/www/html/wordpress
    and
    chcon -R -t httpd_sys_rw_content_t /var/www/html/wordpress
    and maybe do also a restorecon -Rv /var/www/html to be sure.

    Normally a restart for apache is not needed but it won't harm to also give a restart for it by using following code
    systemctl restart httpd

This should solve the update/upgrade problem for WordPress core installations.
ps, this is an example, some could have another document root!

Some resources with much more indeep explanations could be:
Francispereira or Lysender's Daily Log Book and ofcourse SELinux

Hopefully this will help you or other users (as it helped me) on their way.


To update wordpress define following constant in your wp-config.php file

define('FS_METHOD', 'direct');
define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );
define('FTP_BASE', '/var/www/test/');//project directory
define('FTP_CONTENT_DIR', '/var/www/test/wp-content/'); //define wp-content directory path
define('FTP_PLUGIN_DIR ', '/var/www/test/wp-content/plugins/'); //define plugins directory path
define( 'WP_AUTO_UPDATE_CORE', true );
//define ftp details
define('FTP_USER', 'test');
define('FTP_PASS', 'test@123');
define('FTP_HOST', 'ftp.test.com');

Hope this will help you to sort out your problem.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.