Nginx提供静态PHP文件

虽然试图实现缓慢的Wordpress网站的一些caching – 我已经在NGINX级别启用cachig。

然而,它似乎是坚持一个渲染文件,并不想放弃。

这不是在caching中,我试着恢复一切,禁用SendFileclosures,但Nginx仍然希望从5天前提供一个陈旧的文件。

我已经删除了Nginx,重新安装它,重新构build它,没有任何东西。

有什么想法吗?

user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile off; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## # access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; } 

fastcgi_cache_path / var / run / nginx-cache levels = 1:2 keys_zone = NEN_CACHE:100m inactive = 60m; fastcgi_cache_key“$ scheme $ request_method $ host $ request_uri”;

 server { listen 82 default_server; listen [::]:81 default_server ipv6only=on; root /var/www/html/nen; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name localhost; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1M; access_log off; add_header Cache-Control "public"; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_no_cache $no_cache; fastcgi_cache_bypass $no_cache; # fastcgi_cache drm_custom_cache; fastcgi_cache NEN_CACHE; fastcgi_cache_valid 404 60m; fastcgi_cache_valid 200 60m; fastcgi_max_temp_file_size 4m; fastcgi_cache_use_stale updating; add_header X-Cache $upstream_cache_status; } 

来自CURL的HTTP请求

HTTP请求标头

看来这个caching是由WP超级caching,wordpress插件引起的。

我通常会build议你查阅它的文档 ,但是那个插件在几年前遭受了一个非常大的漏洞 ,完全破坏了我对作者的信任。 就个人而言,我会以极大的偏见从服务器中清除它,并使用更高级别的caching层(比如Nginx,或者Varnish ,这非常出色)作为唯一的整页caching系统。

这不是直接的答案,而是告诉你如何自己解决问题。 这些东西往往很难解决,因为你不能发表一切。

回到基础。 从PHP位置删除所有额外的调整的东西。 使用一个简单的PHP文件,只是调用phpinfo()。 尝试通过套接字调用PHP,看看是否有所作为。 检查PHP和nginx访问和错误日​​志以获取有用的信息。 一旦基本工作添加了基本的Wordpress,Nginxcaching。 除非你有很多login用户,否则我不会在内部使用Wordpress的caching,Nginxcaching大部分时间都会为你的网站提供服务。 在不同的nginx位置下,在不同的目录下执行此操作。

这就是我如何调用HHVM,我的PHP解释器,但我调用php-fpm就像你一样。

 upstream php { server 127.0.0.1:9001; } # Inside my php location fastcgi_pass php;