Get the most out of your Centmin Mod LEMP stack
Become a Member

Beta Branch 123.09beta01 add zopfli compression php extension support

Discussion in 'Centmin Mod Github Commits' started by eva2000, Jul 16, 2018.

  1. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
  2. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    check installed zopfli php extension
    Code (Text):
    php --ri zopfli
    
    zopfli
    
    Zopfli support => enabled
    Extension Version => 0.2.0
    Zopfli png recompress => supported
    

    Code (Text):
    php -m | grep zopfli
    zopfli
    

    Centmin Mod 123.09beta01 users can either recompile after cmupdate via centmin.sh menu option 5 or manually compile it first time only
    Code (Text):
    cd /svr-setup
    yum -y install zopfli
    git clone https://github.com/kjdev/php-ext-zopfli
    cd php-ext-zopfli
    git submodule update --init
    phpize
    ./configure --with-php-config=/usr/local/bin/php-config
    make -j$(nproc)
    make install
    echo "extension=zopfli.so" > /etc/centminmod/php.d/zopfli.ini
    fpmrestart
    php --ri zopfli
    
     
  3. rdan

    rdan Premium Member Premium Member

    4,289
    1,040
    113
    May 25, 2014
    Ratings:
    +1,497
    Local Time:
    1:51 PM
    Mainline
    10.2
    Why enable by default?
     
  4. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    123.09beta01 = needs testing :D

    To disable it, set in persistent config file /etc/centminmod/custom_config.inc
    Code (Text):
    PHPZOPFLI='n'
    PHPZOPFLI_ALWAYS='n'
    
     
    • Like Like x 1
  5. rdan

    rdan Premium Member Premium Member

    4,289
    1,040
    113
    May 25, 2014
    Ratings:
    +1,497
    Local Time:
    1:51 PM
    Mainline
    10.2
    What PHP web Script will benefit from that module by the way?
    Or how can we benefit from that? :)
     
  6. eva2000

    eva2000 Administrator Staff Member

    36,333
    7,979
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,287
    Local Time:
    3:51 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Zopfli compression can be used for gzip text or png/webp image compression so depends on if scripts take advantage of it. See Zopfli - Wikipedia

    I was trying to use Zopfli php compression to replace native gzip compression for Wordpress Cache Enabler pre-compressed static html cached files WebPerf - PageSpeed - Wordpress Webpagetest PageSpeed Comparison for CyberPanel 1.7 RC OpenLiteSpeed vs Centmin Mod LEMP as it seemed to work when i manually re-compressed the Cache Enabler's pre-compressed html static cached pages reducing page size. But seems it only worked manually. Using Zopfli php extension and hacked Cache Enabler code didn't work for webpagetest but manual browser viewing worked - so either my hacked code is incomplete or Zopfli php extension bug or webpagetest issue.

    As such I updated it so Zopfli PHP extension is disabled by default unless enabled via persistent config file Beta Branch - disable Zopfli php extension by default

    Example of Zopfli compression WebPerf - Zopfli Optimization: Literally Free Bandwidth.

    FYI, pigz multi-threaded gzip tool has compression levels 1-9 for gzip and level 11 is specifically for Zopfli compression.
    pigz help
    Code (Text):
    pigz -h
    Usage: pigz [options] [files ...]
      will compress files in place, adding the suffix '.gz'.  If no files are
      specified, stdin will be compressed to stdout.  pigz does what gzip does,
      but spreads the work over multiple processors and cores when compressing.
    
    Options:
      -0 to -9, -11        Compression level (level 11, zopfli, is much slower)
      --fast, --best       Compression levels 1 and 9 respectively
      -b, --blocksize mmm  Set compression block size to mmmK (default 128K)
      -c, --stdout         Write all processed output to stdout (won't delete)
      -d, --decompress     Decompress the compressed input
      -f, --force          Force overwrite, compress .gz, links, and to terminal
      -F  --first          Do iterations first, before block split for -11
      -h, --help           Display a help screen and quit
      -i, --independent    Compress blocks independently for damage recovery
      -I, --iterations n   Number of iterations for -11 optimization
      -k, --keep           Do not delete original file after processing
      -K, --zip            Compress to PKWare zip (.zip) single entry format
      -l, --list           List the contents of the compressed input
      -L, --license        Display the pigz license and quit
      -M, --maxsplits n    Maximum number of split blocks for -11
      -n, --no-name        Do not store or restore file name in/from header
      -N, --name           Store/restore file name and mod time in/from header
      -O  --oneblock       Do not split into smaller blocks for -11
      -p, --processes n    Allow up to n compression threads (default is the
                           number of online processors, or 8 if unknown)
      -q, --quiet          Print no messages, even on error
      -r, --recursive      Process the contents of all subdirectories
      -R, --rsyncable      Input-determined block locations for rsync
      -S, --suffix .sss    Use suffix .sss instead of .gz (for compression)
      -t, --test           Test the integrity of the compressed input
      -T, --no-time        Do not store or restore mod time in/from header
      -v, --verbose        Provide more verbose output
      -V  --version        Show the version of pigz
      -z, --zlib           Compress to zlib (.zz) instead of gzip format
      --                   All arguments after "--" are treated as files
    
     
    • Informative Informative x 1
..