What user, group and permissions of files and folders I need for core updates?
Test setups
I tried everything the manual recommended me to. Here are some test setups I used, the setup was recursively used on the WordPress installation.
- Case A: The owner has read/write permissions.
- Case B: The owner and group have read/write permissions.
Every permission case above was tried with the following user and group setup.
- Owner: Apache | Group: Apache
- Owner: Apache | Group: FTPuser
- Owner: FTPuser | Group: FTPuser
- Owner: FTPuser | Group: Apache
Test results
1A:
Could not create directory.
1B:
Could not create directory
2A:
Could not create directory.
2B:
The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php
3A:
Warning: touch(): Unable to create file /home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp because Permission denied in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 155 Warning: unlink(/home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp): No such file or directory in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 457 Download failed.: Destination directory for file streaming does not exist or is not writable.
3B:
Warning: touch(): Unable to create file /home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp because Permission denied in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 155 Warning: unlink(/home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp): No such file or directory in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 457 Download failed.: Destination directory for file streaming does not exist or is not writable.
4A:
Warning: touch(): Unable to create file /home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp because Permission denied in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 155 Warning: unlink(/home/FTPuser/domains/domain.name/public_html/wordpress/wp-content/uploads/wordpress-4.tmp): No such file or directory in /home/FTPuser/domains/domain.name/public_html/wordpress/wp-admin/includes/file.php on line 457 Download failed.: Destination directory for file streaming does not exist or is not writable.
4B:
The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php
These updates always have been a big issue for WordPress, I would like to clarify this let's find a general solution! The installation is hosted on a CentOS 6.6 server running with DirectAdmin.
EDIT:
The custom configuration at wp-config.php I used for these tests, contain the following:
$root='public_html';
define('FTP_USER','username');
define('FTP_PASS','password');
$addr=$_SERVER['SERVER_ADDR'];
$name=$_SERVER['SERVER_NAME'];
$host=$_SERVER['HTTP_HOST'];
$https=$_SERVER['HTTPS'];
$protocol=(!empty($https)&&$https!=='off'||$_SERVER['SERVER_PORT']===443)?'https://':'http://';
$abspath=(strpos(getcwd(),'/wp-admin')!==FALSE)?substr(getcwd(),0,strrpos(getcwd(),'/wp-admin')):getcwd();
$relpath=substr($abspath,strrpos($abspath,$root)+strlen($root));
define('WP_HOME',$protocol.$host.$relpath);
define('WP_SITEURL',$protocol.$name.$relpath);
define('FS_CHMOD_DIR',(02755&~umask())); //FOR CASE A
define('FS_CHMOD_FILE',(0664&~umask())); //FOR CASE A
define('FS_CHMOD_DIR',(02775&~umask())); //FOR CASE B
define('FS_CHMOD_FILE',(0664&~umask())); //FOR CASE B
define('FS_METHOD','ftpext');
define('FTP_BASE',$abspath);
define('FTP_HOST',$addr);
direct
forFS_METHOD
, as CGI will need suPHP or similar. Have you tried direct? So long as PHP can run as the same owner as your files, direct is always the most reliable & efficient filesystem method.