簡體   English   中英

nginx fpm gzip壓縮不起作用

[英]nginx fpm gzip compression not working

我已經用php-fpm + opcache配置了nginx(可能是opcache是​​問題,但是我對此表示懷疑)。 所以:

cat /etc/nginx/conf.d/gzip.conf
gzip on;
gzip_proxied any;
gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss;
gzip_vary on;
gzip_disable "msie6";

phpinfo()輸出:

Phar
Phar: PHP Archive support   enabled
Phar EXT version    2.0.1
Phar API version    1.1.1
SVN revision    $Id: ec8e5fbde7521bb0b03975e5c086f4e10830b36f $
Phar-based phar archives    enabled
Tar-based phar archives     enabled
ZIP-based phar archives     enabled
gzip compression    enabled
bzip2 compression   enabled
OpenSSL support     enabled 

Firebug響應標頭:

Connection  Keep-Alive
Content-Type    application/json;charset=utf-8
Date    Wed, 16 Apr 2014 09:37:54 GMT
Proxy-Connection    Keep-Alive
Server  nginx/1.4.1 (Ubuntu)
Transfer-Encoding   chunked
Vary    Accept-Encoding
Via 1.1 MSFWX
x-powered-by    PHP/5.5.3-1ubuntu2.2

標頭和gzip_types支持PS application / json,我猜是因為將php代碼的編譯位放到RAM中並且從不gzip,所以opcache模塊(最近啟用,此后gzip停止運行)。 我現在應該通過ob_start("ob_gzhandler") gzip ob_start("ob_gzhandler")嗎?

好的,現在效果很好。 解決方案:這是因為有fpm模塊-U需要1st

kill -9 <every fpm process> 

接着

service php5-fpm restart

PS已在系統上測試

PHP 5.5.3-1ubuntu2.2 (cli) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

我希望這會對某人有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM