Why WordPress directory Not writable when folder and files owner and permission look correct?

Discussion in 'Installation/Configuration' started by skysky, May 10, 2023.

  1. skysky

    skysky Member

    Hi
    I have setup many Joomla sites without any issues with ISPconfig (nginx), and today I am migrating my wordpress site to IPSconfig server using root account, then change all folder and files user and group owner. they all look correct to me, but somehow wordpress health tool still shows:
    WordPress directory Not writable

    ANYONE KNOWS WHY?

    2023-05-10_193615.jpg 2023-05-10_193442.jpg 2023-05-10_193350.jpg
    2023-05-10_193651.jpg
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Might be that you accidentally changed the owner of the 'web' directory itself. Try changing it to the web user and client group of the site.
     
  3. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    initially it all looks ok.. possibly some unshown files or folders have the wrong permissions..
    from the webroot, you can run:
    Code:
    find . -type f -exec chmod 644 {} \;
    find . -type d -exec chmod 755 {} \;
    
    that should make sure every file and folder has the correct permissions..
    those work fine for me with apache, i don't see any reason nginx would want different..
    maybe set wp-config.php itself to 640.

    otherwise possibly something in the vhost configuration blocking access? i would say possibly something in .htaccess, but that won't apply to nginx.
    only other thing i can think of is if FS_METHOD is incorrectly defined in wp-config.php
     
  4. skysky

    skysky Member

    thanks for the replies. tried all below and still getting not writable errors for all folder and files.

    1. FS_METHOD defined in wp-config.php
    2023-05-10_201724.jpg

    2. web folder permisson is correct
    2023-05-10_201427.jpg

    3. already run these commands, also tried wp-config.php as 640
    2023-05-10_202242.jpg

    4. nginx Directives in ISPconfig
    2023-05-10_202559.jpg
     
  5. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    To avoid these complications, create shell user for that website and use that to copy and install the files there.
     
  6. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Did you alter the attributes of the files, that may prevent writing.
    You have not shown what is owner, group owner and permissions of the web/ directory itself.
     
    ahrasis likes this.
  7. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    hmm.. don't see anything obviously wrong there.
    file/folder owner/permissions all look ok.
    FS_METHOD can be removed from wp-config.php, i believe it uses direct by default. i know on apache i've never needed to actually bother defining it, but having it there shouldn't be a problem anyway.

    only thing i can think of is one or both of those two 'deny all' settings in the vhost is causing problems.. i have almost no experience of nginx configuration, so i can't say if they're ok or not.
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the nginx directives you used as text in code tags here.
     
  9. skysky

    skysky Member

    after unzip the migration file, all folders and files are with root / root user and group. a shell user for that website can not change them.
     
  10. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    that's because you're unzipping them as root.. if you upload the zip / tar file as the shell user and then unpack it as the shell user, the extracted files should have the correct user/group ownership.
     
  11. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    As @Taleman said, can you show this (ls -lah /var/www/clients/client0/web108)?
     
  12. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    they have shown that in the 2nd image on post #4.
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the content of the nginx directives field as text. Using the wrong directives is causing permission errors in WordPress.
     
  14. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    I missed that thumbnails. Looking at the nginx directives in the fourth thumbnail, deny all may be the culprit and setting php 8.1 there may not be right either.
     
    Last edited: May 10, 2023
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    That's indeed the cause of the issue, this setting enforces PHP to be run as the wrong user www-data by letting nginx connect to the wrong PHP socket.
     
  16. skysky

    skysky Member

    thanks everyone helpful tips. Finally found out the root cause of the permission issue.
    It has nothing to do setting files and folder permission. As Till said it is caused by the wrong setting in "nginx Directives" of ISPconfig. I nerver thought of that place for permission error.

    After remove everything in "nginx Directives" of ISPconfig and only include below, the permission error gone in wordpress now. Thank you so much.
    2023-05-10_235536.jpg
     
  17. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    I hope you mean you keep this following code in it because it is needed for wordpress in nginx to work well.
    Code:
    location / {
                       try_files $uri $uri/ $uri.php /index.php?q=$uri&$args;
    }
    
     
  18. skysky

    skysky Member

    Yes, the below codes needed for wordpress to work.
    location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
    }
     
    ahrasis likes this.

Share This Page