If the problem persists even after fixing owniership and permissions, you might be having an SELinux problem. You’ll need to create a policy to assign the
httpd_sys_rw_content_t selinux security context for the wp-uploads directory and all child files, or for the whole Wordpress directory while you are still configuring it.
You can check extended selinux permissions with:
Make sure you use the full path of your wp-content/uploads dir. Example:
Create policy to enable writing contect to the wp uploads dir and sub-files:
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress/wp-content/uploads(/.*)?"
While you are configuring wordpress, you might want to temporarily enable writing to the whole wordpress directory with the chcon command. These changes will not survive a file system relabel or the execution of the restorecon command. You can do this with:
sudo chcon -t httpd_sys_rw_content_t /var/www/html/wordpress/
The chcon command assigns the selinux security contect temporarily
and then once you are done either or both of the above commands, you need to run restorecon to revert the chcon temporary alterations and to also store the permanent security policy changes made by fcontext
sudo restorecon -v /var/www/html/wordpress/
Whatever you do, don’t disable SELinux or put it in permissive mode. Don’t chmod 777 any directory or files. Its bad security policy. Instead, study how SELinux works and use it properly!
Hope this helps!
(this was done on a CentOS install)