Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0 #6

Open
yunkaiyueming opened this issue Dec 10, 2014 · 16 comments

Comments

@yunkaiyueming
Copy link

when i 'make' phpkafka, it occured the followed issue:

[root@OA-test phpkafka]# make test
Build complete.
Don't forget to run 'make test'.

PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

how can i solve it??? please help me

@yunkaiyueming
Copy link
Author

when i use phpkafka function in my php file:

" Fatal error: Class 'Kafka' not found in /usr/local/www/kafka-php/test_kafka.php on line 5 "

I know i havn't install phpkafka into php_extension rightly, how can i solve it?

@the100rabh
Copy link

Running following commands to load the shared library folder in env variables solved this for me

 LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH

@yunkaiyueming
Copy link
Author

@the100rabh : thanks for your answer, i have solved this problem, i have compiled the 'phpkafka' into php_extension, when i use the next code into my php file:

test_phpkafka.php

produce("topic_name", "message content"); $kafka->consume("topic_name", 1172556); ?>

new 'Kafka' is ok, var_dump($kafka) is : object(Kafka)#1 (0) { }
but '$kafka->produce' and '$kafka->consume' give nothing ,untile nginx server response 502,
what's wrong?

@the100rabh
Copy link

I too tried using consume function thats the one that gives the issue.
produce works fine.

@EVODelavega
Copy link

@yunkaiyueming The problem is that this extension, ATM still requires you to specify what partition to consume from. I'm working on a fix for that, though. for now, you can use my fork (consume-with-meta branch), which adds a couple of methods like getPartitionsForTopic that enable you to set the partition correctly before consuming

@EVODelavega
Copy link

salebab's repo has been abandoned, I've forked it and I'm developing it
further. Currently, the consume-with-meta branch is the one that is most
up-to-date. If you have any issues/suggestions, you can create an issue on
my fork, as my changes will probably not get merged (there's a PR ready and
waiting, but the owner, salebab, hasn't merged them, instead, he's updated
the README file, linking to my fork).

If you want, you can use my fork for testing, mind you, it's far from being
stable

On Tue, Apr 7, 2015 at 11:48 PM, eparisca [email protected] wrote:

@EVODelavega https://github.com/EVODelavega Do you have an estimate on
when you will merge that fork's features? Thank you very much!


Reply to this email directly or view it on GitHub
#6 (comment).

EVODelavega pushed a commit to EVODelavega/phpkafka that referenced this issue Jun 24, 2015
* commit 'b87f564b5490a469449bf7c83d62eee9f7f9e66c':
  update readme
@siyuanmami
Copy link

@EVODelavega
Hi EVODelavega,
I installed phpkafka in CentOS 6.5 by these commands:
ldconfig
/usr/bin/phpize
./configure --enable-kafka --with-php-config=/usr/bin/php-config
make
make install

then I can see kafka.so under /usr/lib64/php/modules.

but when I executed 'service php-fpm restart', it told me:
Starting php-fpm: [16-Oct-2015 17:07:23] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

I have tried export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib as well, but it still not work.

Could you give me some suggestion about it?
Thanks!

@EVODelavega
Copy link

@siyuanmami Not sure, I know there were some issues with building librdkafka on CentOS some time ago, so maybe you want to check the issues on edenhill's librdkafka repo. So far, I've only tested the extension on debian, Slackware, mint and ubuntu. I haven't seen the issue you're reporting on any of those systems, though

@siyuanmami
Copy link

@EVODelavega
Thanks for your help.
I have confirmed with edenhill about it, I should have installed librdkafka library correctly.
Not sure if it is because I am using php-fpm.
I used to install this extension on ubuntu worked with apache, it is fine.

Thanks!

@EVODelavega
Copy link

@siyuanmami php-fpm shouldn't be an issue. AFAIK, it handles the MINIT, RINIT, RSHUTDOWN and MSHUTDOWN cycles in exactly the same way, and as it stands, there's very little in the module init and shutdown functions that could trip PHP up. But having said that: what version are you currently using? What repo, what branch?

@edenhill
Copy link

@EVODelavega This seems to come up quite often, librdkafka.so.1 not being in the library search for the PHP invociation and people dont really know how to fix it, so may I suggest you add some instructions in README?

@siyuanmami
Copy link

@EVODelavega
Thanks you for you help!
I have installed the php extension successfully after I updated /etc/ld.so.conf to include /usr/local/lib !

@EVODelavega
Copy link

@edenhill Done, added some instructions that should be rather dummy-proof to the README on current master

@kaustavha
Copy link

Thanks @the100rabh your solution helped me get kafkacat working.

@abdollahpour
Copy link

I fixed it finally on CentOS 7!! For both CLI and FPM

echo '/usr/local/lib' > /etc/ld.so.conf.d/kafka.conf
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/php/modules:/usr/local/lib"' >> /etc/profile
ldconfig

@amitlokulwar
Copy link

@abdollahpour
I had tried above command that you told but that is also not working.
Still I am getting same error.
Could you please tell me what else step you taken to resolve that issue.
Thank You!!!
kafka

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants