'WordPress File Access Permission

I am trying to upload an image to set a background image for my theme, but I get this error:

Unable to create directory wp-content/uploads/2018/05. Is its parent directory writable by the server?”

I tried to change the access permissions with the help of these blogs:

  1. https://www.digitalocean.com/community/questions/setting-permissions-for-wordpress
  2. https://gist.github.com/Adirael/3383404

But nothing has helped me, and now I also get a 500 error page.

I'm stuck here, can anybody help?

-----------Comment----------- Output Image for ps -ef| grep httpd

I executed this command

find . type f -exec chmod 644 {} \;

and the 500 error page is not being displayed now. I am able to view my web page. But I am still unable to upload a background image. (same error appears "Unable to create directory wp-content/uploads/2018/05. Is its parent directory writable by the server?")



Solution 1:[1]

The following command will fix your issue

sudo chmod -R 777 wp-contents/uploads/

Solution 2:[2]

If you're using Bitnami Lamp then run the following commands in your SSH terminal:

sudo chown -R bitnami:daemon /opt/bitnami/apache/htdocs
sudo chmod -R g+w /opt/bitnami/apache/htdocs
sudo chmod 440 /opt/bitnami/apache/htdocs/wp-config.php
sudo chmod 440 /opt/bitnami/apache/htdocs/.htaccess

and if you're using Bitnami WordPress then run the following commands in your SSH terminal:

sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
sudo chmod -R g+w /opt/bitnami/apps/wordpress/htdocs
sudo chmod 440 /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chmod 440 /opt/bitnami/apps/wordpress/htdocs/.htaccess

The recommended permissions are:

  1. Directories: 775
  2. Files: 640
  3. wp-config.php and.htacess: 440

Thanks

Solution 3:[3]

Maybe is already solved, but can help other users with similar issues.

I made a Shell Script on Debian10 to solve permissions issues. After running it, I make the folder accesible on the Apache2.conf too (WordPress can't Upgrade or Upload Media if not)

What it does:

  1. Set new Owner on all Files and (Sub)Directories ( user:group )

  2. Set Permissions: 755 to Directories and 644 to Files

  3. wp-config.php : Preventing world access for "wp-config.php", leaving it accesible to WordPress (660)

  4. Allow WordPress to manage the "wp-content" (Directories to 755 & Files to 664)

  5. Privatize "wp-content" (Set 755)

Link: https://github.com/ieselisra/wordpress_fix_permissions_debian10/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Balaji.J.B
Solution 2 Sajid Javed
Solution 3 ieselisra