0

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)

3 Answers 3

0

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.

5
  • I tried that, still no joy. My plugins all update through the UI, can add new plugins etc. It's just updating the core that when the error happens. Permission denied in /var/www/html/wp-admin/includes/class-wp-filesystem-direct.php on line 257
    – zerohero
    Commented Feb 2, 2017 at 13:06
  • When I initially had my plugins not being able to update, I follow this: wordpress.stackexchange.com/questions/2743/… and it worked. My core won't update though
    – zerohero
    Commented Feb 2, 2017 at 13:08
  • You must try to add this also define( 'FS_CHMOD_DIR', 0777 ); define( 'FS_CHMOD_FILE', 0777 ); If still you are unable to update then please contact your hosting service provider for permission issue. Commented Feb 2, 2017 at 13:18
  • That didn't work. I am the host. And on all my installs on Debian/NGINX etc, I don't have this issue. Forcing it to 777 file permissions is dangerous, but I did try that as well as the config you suggested, still didn't allow the update to go through
    – zerohero
    Commented Feb 2, 2017 at 13:34
  • even forcing FTP details didn't work
    – zerohero
    Commented Feb 2, 2017 at 13:40
0

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.

1
  • didn't work for me unfortunately
    – zerohero
    Commented Apr 6, 2017 at 18:28
0

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

define('FS_METHOD', 'direct');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.