rtCamp / nginx-helper

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
https://wordpress.org/plugins/nginx-helper/
224 stars 117 forks source link

Permission denied error when using distinct user accounts for nginx and php-fpm, no known errors when using the same account. #327

Open jimgarrigan opened 4 months ago

jimgarrigan commented 4 months ago

Yes, I realize this issue has been previously submitted. I have not seen a resolution, a message which indicates the issue cannot be resolved, or a message which indicates the issue is being investigated.

Any assistance you can provide will be appreciated. Thank you :)

staging environment

Feb 22 14:35:02 XXXX hostname 2024/02/22 14:35:02 [error] 71253#71253: *486 FastCGI sent in stderr: "PHP message: PHP Warning: opendir(XXXXXXXXX fastcgi_cache/d): Failed to open directory: Permission denied in /usr/share/nginx/html/www/wp-content/plugins/nginx-helper/admin/class-purger.php on line 1237" while reading response header from upstream, client: XXXXXXXXXXXXX, server: XXXXXXXXXXXXX, request: "GET /wp-admin/network/plugins.php?_wpnonce=d7a3f1649d&nginx_helper_action=purge&nginx_helper_urls=all&plugin_status=all&s=nginx HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "XXXXXXXXXX", referrer: "https://XXXXXXXXXXXX/wp-admin/network/plugins.php?plugin_status=all&s=nginx"

nginx version: nginx/1.25.4

PHP 8.2.9 (fpm-fcgi) (built: Aug 24 2023 20:35:20) Copyright (c) The PHP Group Zend Engine v4.2.9, Copyright (c) Zend Technologies with Zend OPcache v8.2.9, Copyright (c), by Zend Technologies

WordPress (6.4.3)

NGINX Helper - Version 2.2.4

Nginx #259 I looked at: Conflict Fastcgi cache folder permissions with Nginx #259 I do have the proper purge module installed. https://github.com/FRiCKLE/ngx_cache_purge I obtained the module from https://nginx-extras.getpagespeed.com/modules/cache-purge/ . As noted in the title of my issue, I am encountering the same permission problem as noted in #259.

purge_all permissions problem #283 Same issue: However, when nginx is running as user nginx and PHP is ran as php, the purge_all does not have adequate permissions to clear the cache.

DeeKey commented 4 months ago

Yes - this is an issue! Why not to solve it by using nginx with srtcache module and Redis as a cache storage? Redis has advantages over nginx cach!

jimgarrigan commented 4 months ago

Thank you for the suggestion.

From: DeeKey @.> Sent: Tuesday, February 27, 2024 5:54 AM To: rtCamp/nginx-helper @.> Cc: James Garrigan @.>; Author @.> Subject: Re: [rtCamp/nginx-helper] Permission denied error when using distinct user accounts for nginx and php-fpm, no known errors when using the same account. (Issue #327)

Yes - this is an issue! Why not to solve it by using nginx with srtcache module and Redis as a cache storage? Redis has advantages over nginx cach!

- Reply to this email directly, view it on GitHubhttps://github.com/rtCamp/nginx-helper/issues/327#issuecomment-1966285982, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2J6EFLOWQLO5KHM6YPR5R3YVW3LDAVCNFSM6AAAAABDVRSJZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRWGI4DKOJYGI. You are receiving this because you authored the thread.Message ID: @.**@.>>

josbroers commented 2 months ago

@jimgarrigan maybe this comment can help you?

https://github.com/rtCamp/nginx-helper/issues/63#issuecomment-1813133075

jimgarrigan commented 2 months ago

Thank you

From: Jos Broers @.> Sent: Tuesday, April 23, 2024 5:34 PM To: rtCamp/nginx-helper @.> Cc: James Garrigan @.>; Mention @.> Subject: Re: [rtCamp/nginx-helper] Permission denied error when using distinct user accounts for nginx and php-fpm, no known errors when using the same account. (Issue #327)

@jimgarriganhttps://github.com/jimgarrigan maybe this comment can help you?

63 (comment)https://github.com/rtCamp/nginx-helper/issues/63#issuecomment-1813133075

- Reply to this email directly, view it on GitHubhttps://github.com/rtCamp/nginx-helper/issues/327#issuecomment-2073495701, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2J6EFOM3JWL3GT3KJPTFODY63HVLAVCNFSM6AAAAABDVRSJZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTGQ4TKNZQGE. You are receiving this because you were mentioned.Message ID: @.**@.>>

jimgarrigan commented 2 months ago

Following up ...

I saw no change to the permissions when using setfacl -Rm u:"$user":rwx,g:"$group":rwx,d:u:"$user":rwx,d:g:"$group":rwx "$changed_dir"

I confirmed the values of the three variables via echo statements.

Perhaps, my problem is due to lack of knowledge ... Note: NGINX/WordPress is not within my primary area of expertise.

My alternate solution is the following:

# Set permissions for the changed directory and its contents
# setfacl -Rm u:"$user":rwx,g:"$group":rwx,d:u:"$user":rwx,d:g:"$group":rwx "$changed_dir"
chown -R nginx:web-server-group "$changed_dir"
find "$changed_dir" -type d -exec chmod 0770 {} \;
find "$changed_dir" -type f -exec chmod 0660 {} \;

At my previous job [July 2019 - July 2023], I interacted with Windows servers and created PowerShell scripts to automate tasks. I had written more than 50,000 lines of code. I envision, create, and implement solutions. I created PowerPoint presentations to illustrate work products. https://www.youtube.com/playlist?list=PLgkRipPFmxPPvjxYbTR-iDrGWWwJMJg0y I appropriately altered details.

Jim https://www.garrigan.nychttps://www.garrigan.nyc/

From: James Garrigan Sent: Tuesday, April 23, 2024 5:56 PM To: 'rtCamp/nginx-helper' @.>; rtCamp/nginx-helper @.> Cc: Mention @.***> Subject: RE: [rtCamp/nginx-helper] Permission denied error when using distinct user accounts for nginx and php-fpm, no known errors when using the same account. (Issue #327)

Thank you

From: Jos Broers @.**@.>> Sent: Tuesday, April 23, 2024 5:34 PM To: rtCamp/nginx-helper @.**@.>> Cc: James Garrigan @.**@.>>; Mention @.**@.>> Subject: Re: [rtCamp/nginx-helper] Permission denied error when using distinct user accounts for nginx and php-fpm, no known errors when using the same account. (Issue #327)

@jimgarriganhttps://github.com/jimgarrigan maybe this comment can help you?

63 (comment)https://github.com/rtCamp/nginx-helper/issues/63#issuecomment-1813133075

- Reply to this email directly, view it on GitHubhttps://github.com/rtCamp/nginx-helper/issues/327#issuecomment-2073495701, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A2J6EFOM3JWL3GT3KJPTFODY63HVLAVCNFSM6AAAAABDVRSJZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTGQ4TKNZQGE. You are receiving this because you were mentioned.Message ID: @.**@.>>