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

'No such file or directory' or ''Permission denied' errors, though cache owned by user #332

Open jamminjames opened 3 months ago

jamminjames commented 3 months ago

I can't get nginx-helper to work in Wordpress. I'm using nginx Fastcgi cache for the caching method, and have the settings as suggested in the Wordpress plugin: RT_WP_NGINX_HELPER_CACHE_PATH is set to the correct path, the cache is stored on the same server as WordPress, and we are using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri").

In nginx.conf and www.conf, the user and group are the same as the owner of the Wordpress install directories. I can purge files while logged into the server as that same user. However, I am seeing, for example, unlink() "/var/lib/nginx/cache/e/6e/4cf204232527c7520cf873d969aa56ee" failed (2: No such file or directory) (or 'Permission denied') errors in the nginx error log when I try to purge from Wordpress, depending on if I change the owner/group of the cache directories, which I did to see if anything worked. I've tried changing the cache directory ownership recursively to various settings, including username:username, username:nginx, and nginx:username. The latter is where I got the 'Permission denied' error, otherwise it was 'No such file or directory'.

Also, I have used setfacl to set permissions to rwx for both owner and group.

I have the plugin set to log 'info' level, and it shows a successful "Purged Everything!" message, but the files are still there.

What am I doing wrong? Thanks for any help.

josbroers commented 2 months ago

Hello @jamminjames,

I'd like to verify if you've defined the RT_WP_NGINX_HELPER_CACHE_PATH constant to correspond with the directory specified in your nginx configuration. Did you set it up like this?

define( 'RT_WP_NGINX_HELPER_CACHE_PATH', '/var/lib/nginx/cache/' ); 

Additionally, could you please provide information on the user that nginx runs on, the user that PHP runs on, and the permissions of the directory /var/lib/nginx/cache/?