Close Menu
    Facebook X (Twitter) Instagram
    • Download Cisco Packet Tracer
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Server
    • WordPress
    IT Beginner
    Home»Software»Install and enable zlib on Linux server
    Software

    Install and enable zlib on Linux server

    19/07/2017Updated:20/07/2017No Comments3 Mins Read

    Why need zlib on your linux web server? zlib, gzip and mod_deflate on Apache HTTPD server compress your web pages and serve them to client’s web browsers which can save and reduce bandwidth usage. Most modern web browsers today like Google Chrome or Mozilla Firefox supports both gzip and/or deflate. Enable zlib.output_compression setting in your linux web server will allow gzip compress pages served by PHP.

    zlib is a compression library, written by Jean-loup Gailly and Mark Adler. Zlib works in Linux, Mac OS, even gaming consoles like playStaion 3, Xbox 360 and Wii. Zlib uses deflate() and inflate() algorithm to compress and decompress files. To speed up your website, make sure your web hosting support PHP GZIP compression enabled. To enable gzip, you can either modify php.ini if you have root access to your VPS or dedicated server, or use .htaccess to enable zlib.

    Install zlib (gzip) on Linux web server

    Normally zlib is installed in your web server by default, for some reason if you don’t have zlib installed, here is the command to install zlib to your web server

    For fedora, centos, or redhat based distribution

    # yum install zlib-devel

    For ubuntu, or debian based distribution

    # apt-get update && apt-get install libgcrypt11-dev zlib1g-dev

    Enable zlib (gzip) on Linux web server

    To locate php.ini in your web server, first create info.php and save it at your web root directory, for example in public_html, or www directory

    # nano info.php

    copy and paste this code to info.php and save it.

    <?php
    phpinfo();
    ?>

    Load the info.php you just created in your web browser, since you located that info.php in the root web directory, you should be able to load that file at

    http://yourdomain.com/info.php

    Now look for “Loaded Configuration File” which where php.ini is located in your web server. Next step is to modify php.ini file to enable zlib compression.

    # nano /etc/php.ini

    Search for zlib.output_compression, default value should be off, to enable zlib, simple change to value off to on.

    zlib.output_compression = On

    Next we should set the zlib.output_compression_level value to 6 which is the best compression level without reduce your server preformance. The default value of zlib.output_compression_level is -1 which let your server choose which level to use. In php.ini file, search for

    # zlib.output_compression_level = -1

    Change its value to 6 and uncomment or remove “#” in front of zlib.output_compression_level

    zlib.output_compression_level = 6

    If your host does not support custom php.ini or you don’t have root access to your host, you can enable zlib by adding this code to your .htaccess at your website root directory

    php_flag zlib.output_compression On
    php_value zlib.output_compression_level

    Another method to enable zlib (gzip) to your website without alter php.ini or .htaccess is to add this code right into your PHP scripts before any output

    ini_set('zlib_output_compression','On');

    If you have installed Python but get this error

    can't decompress data; zlib not available.

    configure Python with

    ./configure --with-zlib=/usr/include

    Finally run make command to generate the Python binaries.

    # ./configure
    # make
    # make install
    gzip zlib
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to change date, time, timezone on centos 6
    Next Article Virus and Malware vs Linux

    Related Posts

    CentOS

    How to install XAMPP 1.8.3 with PHP 5.5.11 on Centos Sever

    25/07/2017
    CentOS

    How to install and configure Varnish with Apache on Centos 6

    19/07/2017
    Debian

    How to install firefox on debian 7.3 wheezy

    19/07/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    Tags
    apache centos Centos 6 cuda Desktop Environment dual boot environment featured gnome GUI hostname hosts intel kernel kill lamp server lemp server life MariaDB netflix nginx nvidia password php-fpm phpmyadmin pids processes s.m.a.r.t Security session solid state drive ssd ssh ssh server tag 1 tag 2 Ubuntu upgrade varnish VirtualBox VNC Server web server window manager wordpress xfce
    Facebook X (Twitter) Instagram Pinterest

    Type above and press Enter to search. Press Esc to cancel.

    wpDiscuz