본문 바로가기

리눅스

[리눅스] PHP zip 확장(Extension) 모듈 설치

반응형

PHP zip 확장(Extension) 모듈 설치

테스트 환경

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

zip 패키지 다운로드

https://pecl.php.net/package/zip

libzip.x86_64 : C library for reading, creating, and modifying zip archives

libzip-devel.x86_64 : Development files for libzip

yum info libzip
$ yum info libzip
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirror.navercorp.com
 * extras: mirror.navercorp.com
 * updates: mirror.navercorp.com
Installed Packages
Name        : libzip
Arch        : x86_64
Version     : 0.10.1
Release     : 8.el7
Size        : 104 k
Repo        : installed
From repo   : base
Summary     : C library for reading, creating, and modifying zip archives
URL         : http://www.nih.at/libzip/index.html
License     : BSD
Description : libzip is a C library for reading, creating, and modifying zip archives. Files
            : can be added from data buffers, files, or compressed data copied directly from
            : other zip archives. Changes made without closing the archive can be reverted.
            : The API is documented by man pages.

Available Packages
Name        : libzip
Arch        : i686
Version     : 0.10.1
Release     : 8.el7
Size        : 50 k
Repo        : base/7/x86_64
Summary     : C library for reading, creating, and modifying zip archives
URL         : http://www.nih.at/libzip/index.html
License     : BSD
Description : libzip is a C library for reading, creating, and modifying zip archives. Files
            : can be added from data buffers, files, or compressed data copied directly from
            : other zip archives. Changes made without closing the archive can be reverted.
            : The API is documented by man pages
wget https://pecl.php.net/get/zip-1.20.1.tgz
tar xfz zip-1.20.1.tgz
cd zip-1.20.1
./configure --with-php-config=/usr/bin/php-config

컴파일 에러

$ ./configure --with-php-config=/usr/bin/php-config

...

checking for pkg-config... /usr/bin/pkg-config
checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11

libzip 기존 버전 삭제

$ rpm -qa | grep libzip
libzip-0.10.1-8.el7.x86_64
libzip-devel-0.10.1-8.el7.x86_64
yum remove -y libzip-devel

libzip 패키지 설치

libzip 다운로드

https://libzip.org/download/

cmake 버전

$ cmake --version
cmake version 2.8.12.2
wget https://libzip.org/download/libzip-1.9.0.tar.gz
cd libzip-1.9.0
$ head -n1 CMakeLists.txt
cmake_minimum_required(VERSION 3.0.2)

cmake 버전이 3.0.2 이상 버전이 필요하지만 2.8.12.2 버전이 설치되어 있습니다.


cmake3 설치(cmake 설치)

기존 cmake 삭제(cmake2 삭제)

yum remove -y cmake

cmake 다운로드

https://cmake.org/download/

wget https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2.tar.gz
tar xfz cmake-3.23.2.tar.gz
cd cmake-3.23.2
./bootstrap

bootstrap 중 오류 (OpenSSL)

$ ./bootstrap

...

-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
CMake Error at Utilities/cmcurl/CMakeLists.txt:586 (message):
  Could not find OpenSSL.  Install an OpenSSL development package or
  configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.


-- Configuring incomplete, errors occurred!
See also "/usr/local/src/cmake-3.23.2/CMakeFiles/CMakeOutput.log".
See also "/usr/local/src/cmake-3.23.2/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------
yum install -y openssl-devel
$ ./bootstrap
---------------------------------------------
CMake 3.23.2, Copyright 2000-2022 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++  -std=gnu++1y
Makefile processor on this system is: gmake
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
gmake: `cmake' is up to date.
loading initial cache file /usr/local/src/cmake-3.23.2/Bootstrap.cmk/InitialCacheFlags.cmake
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")
-- Looking for openssl/crypto.h
-- Looking for openssl/crypto.h - found

...

-- Checking support for ARCHIVE_CRYPTO_SHA512_OPENSSL -- found
-- Checking for curses support
-- Checking for curses support - Failed
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - NOTFOUND
-- Performing Test run_pic_test
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/src/cmake-3.23.2
---------------------------------------------
CMake has bootstrapped.  Now run gmake.
make && make install
$ make && make install
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/ProcessUNIX.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/Base64.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/EncodingC.c.o
[  0%] Building C object Source/kwsys/CMakeFiles/cmsys.dir/MD5.c.o

...

-- Installing: /usr/local/share/vim/vimfiles/syntax
-- Installing: /usr/local/share/vim/vimfiles/syntax/cmake.vim
-- Installing: /usr/local/share/emacs/site-lisp/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/bash-completion/completions/cmake
-- Installing: /usr/local/share/bash-completion/completions/cpack
-- Installing: /usr/local/share/bash-completion/completions/ctest

cmake 버전

/usr/local/bin/cmake --version
$ /usr/local/bin/cmake --version
cmake version 3.23.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

링크 설정

ln -s /usr/local/bin/cmake /usr/bin/cmake

libzip 컴파일

cd /usr/local/src/libzip-1.9.0
mkdir build; cd $_
cmake ..
$ cmake ..
-- The C compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
...
-- Found Perl: /usr/bin/perl (found version "5.16.3")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/src/libzip-1.9.0/build
make && make install

컴파일

./configure -with-php-config=/usr/bin/php-config -enable-zip
make && make install
vim /etc/ld.so.conf
$ vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/src/libzip-1.9.0/build/lib
ldconfig
php -m | grep zip
$ php -m | grep zip
zip
728x90
반응형