How to add Nginx object caching for a CMS application (WordPress website)?

I am having trouble applying object caching in Nginx, based on this article (which I visited after failing to understand the official Nginx documentation on this).

I tried to add this to the very end of the http{} block in nginx.conf:

## Nginx FastCGI Cache
    fastcgi_cache_path /var/cache/nginx/fastcgi_temp/cache levels=1:2 keys_zone=czone:100m inactive=60m;
    fastcgi_cache_key $scheme$request_method$host$request_uri;
    fastcgi_cache_lock on;
    fastcgi_cache_use_stale error timeout invalid_header updating http_500;
    fastcgi_cache_valid 200 301 302 60m;
    fastcgi_pass_header Set-Cookie:Set-Cookie;
    fastcgi_pass_header Cookie;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

After adding it I saved and executed nginx -t but I got an error "test failed".

The Nginx error log error gives this:

mkdir() "/var/cache/nginx/fastcgi_temp/cache" failed (2: No such file or directory)`.

Seems that the the PHP mkdir() failed.

My question

What are the correct POSIX directives for /var/ so the PHP function could create /var/cache/nginx/fastcgi_temp/ peacefully? What should be safe?

Or I shouldn't change /var/s POSIX directives and create /var/cache/nginx/fastcgi_temp/ and change only its permissions, but to what?

0
задан 12 April 2018 в 11:23
1 ответ

Njengomntu okhombe kwizimvo, kuya kufuneka wenze isikhombisi se-nginx cache, ekunokwenzeka ukuba iphantsi / var / cache / nginx kwaye unike iimvume ezichanekileyo.

Ndihlala ndisebenzisa

mkdir /var/cache/nginx
chmod 755 /var/cache/nginx
chown nginx:nginx /var/cache/nginx

umnini kuxhomekeke kuseto kunye nosasazo lwakho.

I-Nginx yenza isikhombisi sokugqibela, kumaseva am chown nginx: nignx kunye chmod 700

0
ответ дан 5 December 2019 в 06:14

Теги

Похожие вопросы