본문 바로가기

* 리눅스

[리눅스] PHP rdkafka 확장(Extension)을 설치하는 방법

반응형

PHP rdkafka 확장(Extension)을 설치하는 방법

환경 : nginx - php-fpm

php 버전 확인

php -v

$ php -v
PHP 7.3.27 (cli) (built: Feb  2 2021 10:32:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.27, Copyright (c) 1999-2018, by Zend Technologies

php 저장소 버전 확인

yum info php | egrep 'Name|Arch|Version|Repo' 2

$ yum info php | egrep 'Name|Arch|Version|Repo'
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Name        : php
Arch        : x86_64
Version     : 7.3.33
Repo        : remi-php73

php-devel 패키지 설치(**패키지 설치 시 패치 버전이 업그레이드됩니다.)

yum install -y php-devel

$ yum install -y php-devel

- session 권한 확인(chmod 777 session)

$ ll /var/lib/php | egrep session
drwxrwxrwx 2 root apache 94208 Mar  2 11:14 session

re2c 패키지 설치

yum install -y re2c

$ yum install -y re2c

librdkafka, librdkafka-devel 패키지 설치

yum install -y librdkafka librdkafka-devel

$ yum install -y librdkafka librdkafka-devel

rdkafka 모듈 설치

pecl install rdkafka

$ pecl install rdkafka

php.ini 설정 파일 확인

php --ini | grep php.ini

$ php --ini | grep php.ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini

php.ini 확장 모듈 추가

echo "extension=rdkafka.so" >> /etc/php.ini

$ echo "extension=rdkafka.so" >> /etc/php.ini

rdkafka 모듈 확인

php -m | grep rdkafka

$ php -m | grep rdkafka
rdkafka

웹 서비스(php-fpm) 재기동

systemctl restart php-fpm

$ systemctl restart php-fpm

환경 : apache(httpd) - php

php 버전 확인

php -v

$ /usr/local/php/bin/php -v
PHP 7.3.2 (cli) (built: Aug 10 2020 17:10:03) ( ZTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.2, Copyright (c) 1998-2018 Zend Technologies

re2c 패키지 설치

yum install -y re2c

$ yum install -y re2c

librdkafka, librdkafka-devel 패키지 설치

yum install -y librdkafka librdkafka-devel

$ yum install -y librdkafka librdkafka-devel

php-rdkafka 모듈 설치

$ git clone https://github.com/arnaud-lb/php-rdkafka.git

$ cd php-rdkafka

$ /usr/local/php/bin/phpize

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

$ make install

php.ini 설정 파일 확인

/usr/local/php/bin/php --ini | grep php.ini

$ /usr/local/php/bin/php --ini | grep php.ini
Configuration File (php.ini) Path: /usr/local/apache2/conf
Loaded Configuration File:         /usr/local/apache2/conf/php.ini

php.ini 확장 모듈 추가

echo "extension=rdkafka.so" >> /usr/local/apache2/conf/php.ini

$ echo "extension=rdkafka.so" >> /usr/local/apache2/conf/php.ini

rdkafka 모듈 확인

/usr/local/php/bin/php -m | grep rdkafka

$ /usr/local/php/bin/php -m | grep rdkafka
rdkafka

웹 서비스(php-fpm) 재기동

/usr/local/apache2/bin/apachectl restart

$ /usr/local/apache2/bin/apachectl restart

 

참고사이트

- https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.installation.manual.html

 

728x90
반응형