简体   繁体   中英

nginx fpm gzip compression not working

I have nginx configured with php-fpm + opcache (may be the opcache is the issue, but I doubt in this). So:

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() output:

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 response headers:

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

PS application/json is supported by headers and gzip_types, my guess is that an opcache module (enabled recently, after that moment gzip stops functioning) because of put the compiled bits of a php code into RAM and never gzip it. Should I gzip it through ob_start("ob_gzhandler") now?

Ok, now it works well. Solution: it is because of fpm module - U need 1st to

kill -9 <every fpm process> 

and then

service php5-fpm restart

PS tested on system

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

I hope this will help somebody.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM