728x90

mcrypt.so 확장 모듈 추가하기

 

이것은 CBC에서 DES, TripleDES, Blowfish (기본값), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 및 GOST와 같은 다양한 블록 알고리즘을 지원하는 암호화 모듈입니다.

또한 "무료"로 사용할 수 있었던 RC6 및 IDEA를 지원합니다.

CFB / OFB는 기본적으로 8 비트입니다.

즉, mcrypt_encrypt함수를 통해 php의 양방향 암호화를 진행할 수 있는 모듈입니다

 


이 기능은 PHP 7.1.0에서 더 이상 사용되지 않으며 PHP 7.2.0에서 제거되었습니다.
이 기능의 대안으로 아래와 같은 것을 사용할 수 있습니다.
- Sodium (PHP 7.2.0 부터 사용가능)
- OpenSSL


 

들어가기전...

PHP를 소스(Source)로 설치한 경우 입니다.

PHP-5.3.9 버전을 기준으로 설명합니다.

PHP-5.3.9 압축파일을 /usr/local/src 폴더에서 풀어놓고 설치를 하였습니다.

/usr/local/src/php-5.3.29/ 입니다.

설치한 폴더 옵션인 prefix는 /usr/local/php 로 해뒀습니다.

/usr/local/php 에 설치가 되어 있습니다.

 

mongo.so 확장모듈을 설치하기 위해서는 pecl 툴을 사용합니다.

 


-- 설치된 폴더 이동

cd /usr/local/src/php-5.3.29/ext

 

-- /usr/local/php/bin/phpize 명령어 에러 발생!!

libmcrypt 라이브러리에서 mcrypt.h 가 없다는 에러가 발생하면서 컴파일이 안되는 경우 발생

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

 

[root@national-pension-contents mcrypt]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
configure.in:3: warning: prefer named diversions
configure.in:3: warning: prefer named diversions
[root@national-pension-contents mcrypt]# ./configure --with-php-config=/usr/local/php/bin/php-config 
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local/php
checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-debug-zts-20090626
checking for PHP installed headers prefix... /usr/local/php/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for mcrypt support... yes, shared
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

 

-- Please reinstall libmcrypt. 발생시 libmcrypt  라이브러리 설치

1. yum 설치 방법 

# yum list php-mcrypt

# yum install php-mcrypt

 

 

2. mcrypt 모듈 다운로드 소스 설치 방법

가. 소스 다운로드 https://ko.osdn.net/projects/sfnet_mcrypt/downloads/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/

 

나. 설치하기 
# tar zxf libmcrypt-2.5.8.tar.gz 
# cd libmcrypt-2.5.8/

#  ./configure --prefix=/usr/local/
# make && make check && make install

 

libmcrypt-2.5.8.tar.gz  libssh2-1.8.1.tar.gz    
[root@national-pension-contents src]# tar zxf libmcrypt-2.5.8.tar.gz 
[root@national-pension-contents src]# cd libmcrypt-2.5.8/
[root@national-pension-contents libmcrypt-2.5.8]# ls
acinclude.m4    buildconf     config.log     COPYING.LIB  install-sh      libmcrypt.spec.in  Makefile.in    README
aclocal.m4      ChangeLog     config.status  depcomp      KNOWN-BUGS      libtool            missing        src
AUTHORS         config.guess  config.sub     doc          lib             ltmain.sh          mkinstalldirs  stamp-h1
autom4te.cache  config.h      configure      include      libltdl         Makefile           modules        THANKS
autoscan.log    config.h.in   configure.in   INSTALL      libmcrypt.spec  Makefile.am        NEWS           TODO
[root@national-pension-contents libmcrypt-2.5.8]# ./configure --prefix=/usr/local/


..............

*** Dynamic loading has been disabled
checking which algorithms to include into library... cbc cfb ctr ecb ncfb nofb ofb stream threeway cast-128 gost rijndael-128 safer-sk64 twofish  arcfour cast-256 loki97 rijndael-192 saferplus wake  blowfish-compat des rijndael-256 serpent xtea  blowfish enigma rc2 safer-sk128 tripledes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required

..............


config.status: creating modules/Makefile
config.status: creating modules/modes/Makefile
config.status: creating modules/algorithms/Makefile
config.status: creating lib/libmcrypt-config
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default-1 commands




[root@national-pension-contents libmcrypt-2.5.8]# make && make check && make install


............



/bin/install -c .libs/libmcrypt.lai /usr/local//lib/libmcrypt.la
PATH="$PATH:/sbin" ldconfig -n /usr/local//lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local//lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
test -z "/usr/local//share/aclocal" || mkdir -p -- "/usr/local//share/aclocal"
 /bin/install -c -m 644 'libmcrypt.m4' '/usr/local//share/aclocal/libmcrypt.m4'
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/lib'
make[1]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/lib'
Making install in src
make[1]: Entering directory `/usr/local/src/libmcrypt-2.5.8/src'
make[2]: Entering directory `/usr/local/src/libmcrypt-2.5.8/src'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/src'
make[1]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/src'
Making install in doc
make[1]: Entering directory `/usr/local/src/libmcrypt-2.5.8/doc'
make[2]: Entering directory `/usr/local/src/libmcrypt-2.5.8/doc'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local//man/man3" || mkdir -p -- "/usr/local//man/man3"
 /bin/install -c -m 644 './mcrypt.3' '/usr/local//man/man3/mcrypt.3'
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/doc'
make[1]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/doc'
make[1]: Entering directory `/usr/local/src/libmcrypt-2.5.8'
make[2]: Entering directory `/usr/local/src/libmcrypt-2.5.8'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.8'
make[1]: Leaving directory `/usr/local/src/libmcrypt-2.5.8'

 

 

-- ./configure --with-php-config=/usr/local/php/bin/php-config  재실행

#./configure --with-php-config=/usr/local/php/bin/php-config

# make && make install

 

[root@national-pension-contents libmcrypt-2.5.8]# ls
acinclude.m4    buildconf     config.log     COPYING.LIB  install-sh      libmcrypt.spec.in  Makefile.in    README
aclocal.m4      ChangeLog     config.status  depcomp      KNOWN-BUGS      libtool            missing        src
AUTHORS         config.guess  config.sub     doc          lib             ltmain.sh          mkinstalldirs  stamp-h1
autom4te.cache  config.h      configure      include      libltdl         Makefile           modules        THANKS
autoscan.log    config.h.in   configure.in   INSTALL      libmcrypt.spec  Makefile.am        NEWS           TODO
[root@national-pension-contents libmcrypt-2.5.8]# pwd
/usr/local/src/libmcrypt-2.5.8
[root@national-pension-contents libmcrypt-2.5.8]# cd ../php-5.3.29/ext/mcrypt/
[root@national-pension-contents mcrypt]# ./configure --with-php-config=/usr/local/php/bin/php-config 
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local/php
checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-debug-zts-20090626
checking for PHP installed headers prefix... /usr/local/php/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for mcrypt support... yes, shared
checking for libmcrypt version... >= 2.5.6
checking for mcrypt_module_open in -lmcrypt... no
checking for mcrypt_module_open in -lmcrypt... yes
checking for ld used by cc... /bin/ld
checking if the linker (/bin/ld) is GNU ld... yes
checking for /bin/ld option to reload object files... -r
checking for BSD-compatible nm... /bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
[root@national-pension-contents mcrypt]# make && make install
/bin/sh /usr/local/src/php-5.3.29/ext/mcrypt/libtool --mode=compile cc  -I. -I/usr/local/src/php-5.3.29/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/src/php-5.3.29/ext/mcrypt/include -I/usr/local/src/php-5.3.29/ext/mcrypt/main -I/usr/local/src/php-5.3.29/ext/mcrypt -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/php-5.3.29/ext/mcrypt/mcrypt.c -o mcrypt.lo 
mkdir .libs
 cc -I. -I/usr/local/src/php-5.3.29/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/src/php-5.3.29/ext/mcrypt/include -I/usr/local/src/php-5.3.29/ext/mcrypt/main -I/usr/local/src/php-5.3.29/ext/mcrypt -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php-5.3.29/ext/mcrypt/mcrypt.c  -fPIC -DPIC -o .libs/mcrypt.o
/bin/sh /usr/local/src/php-5.3.29/ext/mcrypt/libtool --mode=compile cc  -I. -I/usr/local/src/php-5.3.29/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/src/php-5.3.29/ext/mcrypt/include -I/usr/local/src/php-5.3.29/ext/mcrypt/main -I/usr/local/src/php-5.3.29/ext/mcrypt -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/php-5.3.29/ext/mcrypt/mcrypt_filter.c -o mcrypt_filter.lo 
 cc -I. -I/usr/local/src/php-5.3.29/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/src/php-5.3.29/ext/mcrypt/include -I/usr/local/src/php-5.3.29/ext/mcrypt/main -I/usr/local/src/php-5.3.29/ext/mcrypt -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php-5.3.29/ext/mcrypt/mcrypt_filter.c  -fPIC -DPIC -o .libs/mcrypt_filter.o
/usr/local/src/php-5.3.29/ext/mcrypt/mcrypt_filter.c: In function ‘php_mcrypt_filter_create’:
/usr/local/src/php-5.3.29/ext/mcrypt/mcrypt_filter.c:210:2: warning: passing argument 1 of ‘mcrypt_module_open’ discards ‘const’ qualifier from pointer target type [enabled by default]
  mcrypt_module = mcrypt_module_open(cipher, algo_dir, mode, mode_dir);
  ^
In file included from /usr/local/include/mcrypt.h:4:0,
                 from /usr/local/src/php-5.3.29/ext/mcrypt/mcrypt_filter.c:25:
/usr/local/include/mutils/mcrypt.h:38:9: note: expected ‘char *’ but argument is of type ‘const char *’
  MCRYPT mcrypt_module_open(char *algorithm,
         ^
/bin/sh /usr/local/src/php-5.3.29/ext/mcrypt/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/local/src/php-5.3.29/ext/mcrypt/include -I/usr/local/src/php-5.3.29/ext/mcrypt/main -I/usr/local/src/php-5.3.29/ext/mcrypt -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -o mcrypt.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/local/src/php-5.3.29/ext/mcrypt/modules  mcrypt.lo mcrypt_filter.lo -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lmcrypt
cc -shared  .libs/mcrypt.o .libs/mcrypt_filter.o  -Wl,--rpath -Wl,/usr/local//lib -Wl,--rpath -Wl,/usr/local//lib -L/usr/local/lib /usr/local//lib/libmcrypt.so  -Wl,-rpath -Wl,/usr/local/lib -Wl,-soname -Wl,mcrypt.so -o .libs/mcrypt.so
creating mcrypt.la
(cd .libs && rm -f mcrypt.la && ln -s ../mcrypt.la mcrypt.la)
/bin/sh /usr/local/src/php-5.3.29/ext/mcrypt/libtool --mode=install cp ./mcrypt.la /usr/local/src/php-5.3.29/ext/mcrypt/modules
cp ./.libs/mcrypt.so /usr/local/src/php-5.3.29/ext/mcrypt/modules/mcrypt.so
cp ./.libs/mcrypt.lai /usr/local/src/php-5.3.29/ext/mcrypt/modules/mcrypt.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/php-5.3.29/ext/mcrypt/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/src/php-5.3.29/ext/mcrypt/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20090626/

 

'/usr/local/php/lib/php/extensions/no-debug-zts-20090626/'에 보시면 mcrypt.so 파일이 보일 겁니다.

[root@national-pension-contents mcrypt]# ll  /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
total 2728
-rwxr-xr-x 1 root root  159329 Feb 28 15:26 mcrypt.so
-rwxr-xr-x 1 root root 1949145 Feb 28 14:37 mongo.so
-rwxr-xr-x 1 root root  107970 Feb 28 14:36 pcntl.so
-rwxr-xr-x 1 root root  570358 Feb 28 14:56 zip.so
[root@national-pension-contents mcrypt]# 

 

그냥 아래 내용을 긁어서 사용하세요.

# libmcrypt 소스 파일 설치 

wget https://ko.osdn.net/projects/sfnet_mcrypt/downloads/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/
tar zxf libmcrypt-2.5.8.tar.gz 
cd libmcrypt-2.5.8/
./configure --prefix=/usr/local/
make && make check && make install


#mcrypts.so확장 모듈 설치

cd /usr/local/src/php-5.3.29/ext/mcrypt
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

+ Recent posts