机库阁 经验分享 详解CentOS 8.2 图文源码安装zlib 1.2.11

详解CentOS 8.2 图文源码安装zlib 1.2.11

点击数:0

简介:

zlib is designed to be a free, general-purpose, legally unencumbered — that is, not covered by any patents — lossless data-compression library for use on virtually any computer hardware and operating system. The zlib data format is itself portable across platforms. Unlike the LZW compression method used in Unix compress(1) and in the GIF image format, the compression method currently used in zlib essentially never expands the data. (LZW can double or triple the file size in extreme cases.) zlib’s memory footprint is also independent of the input data and can be reduced, if necessary, at some cost in compression. A more precise, technical discussion of both points is available on another page.

zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression). Jean-loup is also the primary author of gzip, the author of the comp.compression FAQ list and the former maintainer of Info-ZIP’s Zip; Mark is also the author of gzip’s and UnZip’s main decompression routines and was the original author of Zip. Not surprisingly, the compression algorithm used in zlib is essentially the same as that in gzip and Zip, namely, the `deflate’ method that originated in PKWARE’s PKZIP 2.x.

zlib被设计成一个免费的、通用的、法律上不受阻碍(即没有被任何专利覆盖) 的无损数据压缩库。zlib几乎适用于任何计算器硬件和操作系统。zlib本身的数据格式可以进行跨平台的移植。 与在Unix上适用的LZW压缩方法 以及 GIF 图像压缩不同, zlib中适用的压缩方法从不对数据进行拓展。(LZW在极端情况下会导致文件大小变为原来的两倍、甚至三倍)。zlib的内存占用也是独立于输入数据的,并且在必要的情况下可以适当减少部分内存占用。

zlib 适用于数据压缩的函式库,由Jean-loup Gailly (负责compression)和 Mark Adler (负责decompression)开发。Jean-loup也是gzip的主要作者,是comp.compression FAQ列表的作者,也是Info-ZIP 的zip前维护者;Mark也是gzip和UnZip的主解压例程的作者,也是Zip的原始作者。毫不奇怪,zlib中使用的压缩算法与gzip和Zip中的压缩算法本质上是相同的,即源自PKWARE的PKZIP 2.x的“deflate”方法。

说明:

zlib是系统的底层库,如没有必要,一定要在了解的基础上进行安装或者升级,以免出现问题,在进行操作之前,一定要了解其风险,如果操作不当,会导致很多命令无法使用,甚至系统无法重启


由于需要安装nginx,并且nginx是使用zlib对http的内容进行gzip,而zlib库恰巧也提供很多的压缩和解压缩的方式,所以需要在centos上安装zlib库,前提是系统没有自带zlib,或者系统自带的版本不符合自己的需要

方法一源码安装:

1)获取zlib编译安装包,在http://www.zlib.net/上可以获取当前最新的版本

wget http://www.zlib.net/zlib-1.2.11.tar.gz

如果以上地址无法下载或者下载慢的话,可以从以下地址下载对应的zlib文件并且上传到个人服务器进行后续操作http://download.youceba.com/dir/25806543-41266780-396a33   

2)解压缩zlib-1.2.11.tar.gz包

tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11    

3)进入解压缩目录,执行命令

./configure –prefix=/data/install/zlib //手动指定zlib的安装目录,具体参数可以查看–help

    4)编译

make

5)安装

make install

注意:从输出可以看出,make install 这一步实际上是对编译生成zlib相关文件的一个分发,也就是将编译生成文件拷贝到相关路径,我们在做离线升级安装包的时候,直接拷贝这些命令加到脚本就可以了!

6)执行以下命令,使之生效

echo “/data/install/zlib/lib” >> /etc/ld.so.conf

ldconfig

查看ld.so.conf文件内容如下:

至此,zlib就已经完全安装完毕


方法二安装:

yum install -y zlib zlib-devel


常用备查命令:

1. 查看zlib版本

yum info zlib

2. 添加lib库自动搜索路径并使之生效

echo “/data/install/zlib/lib” >> /etc/ld.so.conf

ldconfig

本文来自网络,不代表机库阁立场,转载请注明出处:http://www.jikuge.com/127/

作者: zhuifeng

上一篇
下一篇

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

关注微博
返回顶部