PHP Velho Oeste 2024

phpize로 공유 PECL 확장모듈 컴파일하기

가끔은, pecl 인스톨러를 사용하는것이 선택사항이 아닐수 있습니다. 방화벽뒤에 있거나, CVS의 릴리즈되지 않은 확장 모듈처럼 설치할 PECL 호환패키지가 없는것이 이유가 될 것입니다. 이런 확장모듈을 빌드할 필요가 있을 경우, 좀더 하위 레벨의 빌드툴을 사용하여 직접 빌드할수가 있습니다.

phpize 명령은 PHP 확장모듈을 위한 빌드환경을 만들기 위해 사용합니다. 아래의 샘플코드에는 확장모듈의 소스가 extname 이름의 디렉터리 안에 있습니다.:

$ cd extname
$ phpize
$ ./configure
$ make
# make install

성공적으로 인스톨되었다면 extname.so 이 생성될것이고, 그것을 PHP의 확장모듈 디렉터리 안에 위치시킬 것입니다. 확장 모듈을 사용하기전에 php.iniextension=extname.so 라인의 추가가 필요할 것입니다.

만약에 시스템이 phpize 명령을 찾지 못하고, 미리컴파일된 패키지(RPM 같은)를 사용하고 있다면, 적절한 버전의 PHP devel 패키지를 설치하도록 합니다. 그것들은 대체로 phpize 명령 이외에 PHP와 확장모듈을 빌드할 적절한 헤더파일을 포함합니다.

phpize --help 를 실행하면 추가적인 사용법 정보를 볼수가 있습니다.

add a note add a note

User Contributed Notes 5 notes

up
67
Brian
16 years ago
If you have multiple PHP versions installed, you may be able to specify for which installation you'd like to build by using the --with-php-config option during configuration.

--with-php-config=[Insert path to proper php-config here]

For example (my case):
./configure --with-php-config=/usr/local/php5/bin/php-config5
up
0
admin at eexit dot net
11 years ago
When compiling an extension for a stack which is 64 bits (for example) and your compiler is configured to compile in 32 bits, you can manually compile your extensions using C flags before your configure.

Example: my system compiler is 32 bits and my stack is 64 bits. To compile my xdebug:

# phpize
# CFLAGS=-m64 CPPFLAGS=-m64 CCASFLAGS=-m64 ./configure --enable-xdebug
# gmake
# file modules/xdebug.so
modules/xdebug.so:      ELF 64-bit LSB dynamic lib AMD64 Version 1, dynamically linked, not stripped, no debugging information available
up
-6
Glen
16 years ago
When you have multiple installations of PHP, running phpize from a specific installation will not force the module to be compiled with that installation's include files.

In my case, I had a standard PHP distribution installed, and am evaluating Zend Core / Zend Platform, which installed it's own Apache & PHP in a /usr/local/Zend/.. install path.  It was missing the json.so module, so I had to compile my own.

Running Zend Core's phpize, the output indicates that configuration for that module will occur.  But when running ./configure, the standard installation's include files are used.  The result json.so being compiled against the wrong PHP would not load when Zend Core's php initializes.

The only way I could see to correct the situation was to temporarily change the standard PHP include path to point to the Zend Core's include files.  In my case, I made a backup copy of /usr/include/php5 and did a "ln -s /usr/local/Zend/Core/include/php/ /usr/include/php5".
up
-9
gautama dot himawan at yahoo dot com
9 years ago
If you failed to run phpize command, then you should install php-devel package. Command line to install the php-devel package using yum is: yum install php-devel.

If you failed to compile the PECL extension, then you should install gcc package. Command line to install the gcc package using yum is: yum install gcc.
up
-8
dmytton at php dot net
18 years ago
In some situations (e.g. on a cPanel server), the built extension will not be placed into the correct extensions directory by the make install process. Use your phpinfo() output to determine what the correct extension_dir path is and move the generated .so file into that directory. The extension=extname.so line in php.ini will then find the extension file correctly.
To Top