加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

使用Nginx fastcgi_cache php-fpm缓存和静态文件缓存配置?

发布时间:2020-12-13 21:26:41 所属栏目:Nginx 来源:网络整理
导读:Nginx维基非常模糊,解释如何正确设置nginx与php-fpm与fastcgi_caching为具有cookie的网站,即wordpress,drupal,vbulletin等. 我从http://vbtechsupport.com/796/下载了一个名为centmin的修改后的nginx bash shell安装脚本,同时它通过shell脚本自动安装nginx v

Nginx维基非常模糊,解释如何正确设置nginx与php-fpm与fastcgi_caching为具有cookie的网站,即wordpress,drupal,vbulletin等.

我从http://vbtechsupport.com/796/下载了一个名为centmin的修改后的nginx bash shell安装脚本,同时它通过shell脚本自动安装nginx v1.0.2,php 5.3.6 php-fpm,mariadb 5.2.6 mysql,memcached 1.4.5服务器和siege基准测试缺少用于为缓存php设置fastcgi_caching的配置参数.

它还缺少为本地提供的文件缓存静态文件的设置.将静态文件驻留在同一磁盘上时,使用proxy_cache是??否有任何意义?

任何人都有一些提示和信息链接信息阅读教程正确设置php(php-fpm)fastcgi_caching以及缓存本地驻留静态文件?

谢谢

最佳答案

Is there any point in using proxy_cache for static files when they reside on the same disk ?

没有,没有.它可以通过磁盘访问静态文件.

Anyone got some tips and info links to info to read up on tutorials for proper setup for php (php-fpm) fastcgi_caching as well as for caching locally residing static files ?

看看那里的各种proxy_caching教程,特别是那些从Apache代理WordPress的教??程 – fastcgi_caching几乎完全相同,而且对于proxy_caching来说,几乎无疑对fastcgi_caching也有效.

我现在碰巧正在研究这个完全相同的问题.到目前为止,除了会计cookie之外,我还有它的工作,但这只是一系列简单的if指令,用于为fastcgi_cache_key指令设置其他变量. This page对你来说应该是非常有用的;只需跳到proxy_caching配置并将所有这些proxy_ *指令更改为fastcgi_ *(这是我一直关注的,但要注意if is evil并且不应该驻留在location指令中……).

当我完全自己完成后,我会在我的博客上发布它(链接在我的个人资料中;如果我把这个链接放在我的帖子中,我会再遇到麻烦).很遗憾,还没有任何fastcgi_caching指南已经存在,所以我不能指出你除了我的博客以外的任何东西(即使它还没有到那里……).

编辑添加:这是我当前的fastcgi_caching配置.就像我说的那样,它缺乏对cookie的任何解释,但它确实在很大程度上实际上是功能性的.

在处理我的.php文件的位置块中,我添加了:

#Caching parameters
fastcgi_cache one;
#I use host here to account for the fact that I have multiple WP instances
fastcgi_cache_key $scheme$host$request_uri;

fastcgi_cache_valid  200 302 304 30m;
fastcgi_cache_valid  301 1h;
fastcgi_cache_valid  any 5m;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;

这与我在http块中添加的内容有关:

# configure cache log
log_format cache '$remote_addr - $host [$time_local]  '
                 '"$request" $status $upstream_cache_status $body_bytes_sent '
                 '"$http_referer" "$http_user_agent"';


# Configure cache and temp paths
fastcgi_cache_path /var/cache/nginx levels=1:2
                   keys_zone=one:100m
                   inactive=7d max_size=10g;
fastcgi_temp_path /var/cache/nginx/tmp;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读