• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question 【Urgent】Please let me know the setting of Nginx of Plesk, using FastCGI Cashe to make WordPress fast

Nginx

  • Nginx

    Votes: 0 0.0%
  • Nginx

    Votes: 1 100.0%

  • Total voters
    1

ZGUNDAM

New Pleskian
【Urgent】Please let me know the setting of Nginx of Plesk, using FastCGI Cashe to make WordPress faster.


The current settings in /etc/nginx/nginx.conf are as follows.



[root@0120-246-070 ~]# vi /etc/nginx/nginx.conf
[root@0120-246-070 ~]# nginx -t
nginx: [emerg] "fastcgi_cache" zone "wp_cache" is unknown in /etc/nginx/nginx.conf:72
nginx: configuration file /etc/nginx/nginx.conf test failed
[root@0120-246-070 ~]# vi /etc/nginx/nginx.conf
[root@0120-246-070 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/nginx/fastcgi-cache" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
[root@0120-246-070 ~]# cd /var/nginx
-bash: cd: /var/nginx: No such file or directory
[root@0120-246-070 ~]# cd /var
[root@0120-246-070 var]# ls
cache drweb lib log nis preserve run www
cvs empty local mail opt proftpd.delay spool yp
db games lock named parallels qmail tmp
[root@0120-246-070 var]# cd ./run
[root@0120-246-070 run]# ls
atd.pid imapd.pid nginx-cache setrans
auditd.pid imapd-ssl.pid nginx.pid snmpd.pid
authdaemon.courier-imap kav ntpd.pid spamassassin
console lshttpd.pid php-fpm spamd.pid
ConsoleKit mailman plesk-php56-fpm.pid sshd.pid
courier-authdaemon.pid messagebus.pid plesk-php71-fpm.pid sw-collectd.pid
couriersslcache mod_fcgid plymouth sw-cp-server.pid
crond.pid monit.state pop3d.pid sw-engine.pid
cron.reboot mysqld pop3d-ssl.pid sw-engine.sock
dbus named portreserve syslogd.pid
fail2ban named.pid proftpd utmp
faillock netreport saslauthd winbindd
httpd net-snmp sepermit xinetd.pid
[root@0120-246-070 run]# vi /etc/nginx/nginx.conf
[root@0120-246-070 run]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@0120-246-070 run]# service nginx restart
Starting nginx: [ OK ]
[root@0120-246-070 run]# top
top - 20:50:17 up 1 day, 37 min, 1 user, load average: 2.78, 2.83, 3.06
Tasks: 137 total, 6 running, 131 sleeping, 0 stopped, 0 zombie
Cpu(s): 79.2%us, 18.0%sy, 0.0%ni, 0.8%id, 1.0%wa, 0.0%hi, 1.0%si, 0.0%st
Mem: 1478508k total, 1402072k used, 76436k free, 70540k buffers
Swap: 1048572k total, 212304k used, 836268k free, 928132k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6068 mysql 20 0 1144m 36m 5072 S 37.1 2.6 728:34.04 mysqld
24144 erodouji 20 0 498m 40m 24m R 35.7 2.8 5:04.15 php-fpm
24159 erodouji 20 0 497m 39m 24m R 31.8 2.7 2:41.25 php-fpm
24185 erodouji 20 0 497m 39m 24m R 31.1 2.7 1:08.20 php-fpm
24157 erodouji 20 0 498m 40m 24m R 30.4 2.8 2:09.24 php-fpm
24158 erodouji 20 0 498m 40m 24m R 28.5 2.8 3:03.02 php-fpm
24054 nginx 20 0 53160 6972 1952 S 2.0 0.5 0:46.17 nginx
323 root 20 0 0 0 0 S 0.3 0.0 0:16.13 kjournald
11404 root 30 10 236m 3592 2092 S 0.3 0.2 0:11.19 spamd
24057 root 20 0 15020 1340 1008 R 0.3 0.1 0:07.85 top
24201 root 20 0 350m 36m 20m S 0.3 2.6 0:00.21 sw-engine
1 root 20 0 19360 1080 888 S 0.0 0.1 0:00.99 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.07 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:00.65 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/0
6 root RT 0 0 0 0 S 0.0 0.0 0:00.15 watchdog/0
[root@0120-246-070 run]# cd /etc/nginx/
[root@0120-246-070 nginx]# vi nginx.conf

#user nginx;
worker_processes 1;
worker_rlimit_nofile 16384;
#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 365;
#tcp_nodelay on;



gzip on;
gzip_min_length 0;
gzip_buffers 4 8k;
gzip_types text/plain text/xml application/x-javascript text/css;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";




##
# Fastcgi_cache Settings
##
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:4m inactive=7d max_size=50m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;





server_tokens off;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
 
Could anyone post a WORKING solution with Plesk? The built-in microcache does not seem to be compatible with the linked article. Anything that is proofed to be working would be appreciated...
 
@papak : Did you check the in-built micro cache or did you implement the suggestions and configuration described in the linked article?
 
On Plesk 17.8 you can activate per domain Nginx Cache under Apache & nginx, what you already know and you can skip step 1. Just proceed with Step 2. Plesk write in /var/cache/nginx for any domain separately. Check proper path to add in WordPress NGINX Caching Plugin. Under Apache & nginx settings => Additional nginx directives I have:

set $skip_cache 0;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}

if ($query_string != "") {
set $skip_cache 1;
}

# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}

if (!-e $request_filename) {
rewrite ^(.+)$ /index.php break;
}

if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}

location ~* "^/wp-content/.*\.php" { allow 37.59.242.16; allow 212.35.24.137; allow 62.2.206.118; deny all; }

location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf)$ {
expires 365d;
}
location ~* \.(pdf|html|swf)$ {
expires 90d;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf)$ {
expires 90d;
add_header Cache-Control "public, no-transform";
}


location ~ \.php$ {
try_files $uri =404;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache new.virtualserver.ch_fastcgi;
fastcgi_cache_valid 60m;
add_header X-FastCGI-Cache $upstream_cache_status;
}

That's what I did.
 
Okay, that seems to get me one step closer. According to the article I have installed nginx cache plugin but it moans about a missing cache zone path.
There is a cache folder for the website under /var/cache/nginx. Any idea @papak where I went wrong?
 
Last edited:
Back
Top