user1762087
user1762087

Reputation: 460

zeromq working for phpcli, but not for apache

First of all, I checked all related questions, but in my case it must be something else (I tried the solutions from there);

I installed zeromq following these instructions http://zeromq.org/bindings:php and everything works just fine when I run my php script from CLI

Problem is running from apache server, I get the

Fatal error: Class 'ZMQContext' not found in /var/www/i.php on line 19

line 19 is

$context = new ZMQContext();

What I tried:

1)I ran the php_info(), I found out where my php.ini files are

 /etc/php5/apache2/php.ini
 /etc/php5/apache2/conf.d/10-php_pdo_mysql.ini, 
 /etc/php5/apache2/conf.d/10-zmq.ini,
 and so on...

So I opened these files and add line "extension=zmq.so"

Did not help.

2)I added following lines to the beginning of my script:

use \ZMQContext;
use \ZMQ;

Again, did not help

3) I checked the apache error logs and find this:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626
/zmq.so' - /usr/lib/php5/20090626/zmq.so:
 cannot open shared object file: No such file or directory in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626
/zmq.so' - /usr/lib/php5/20090626/zmq.so: cannot open shared object file: No such 
file or directory in Unknown on line 0

4) So I checked, where the zmq.so actually is on my machine:

user@wb:~$ sudo find / -name zmq.so
/home/user/php-zmq/modules/zmq.so
/home/user/php-zmq/.libs/zmq.so
/var/www/push/php-zmq/modules/zmq.so
/var/www/push/php-zmq/.libs/zmq.so
/usr/lib/php5/20100525/zmq.so
/usr/local/lib/php/extensions/no-debug-non-zts-20121212/zmq.so

So do you have any suggestion what else might be wrong? Thank you

Upvotes: 1

Views: 1319

Answers (2)

user1762087
user1762087

Reputation: 460

So I finally solve it out (thaks to lxg for pointing me to the right direction)

First of all I have to manually remove my compiled versions of apache and php (following some tutorials here on SO)

then removing php and apache with apt-get

reinstalling php and apache with apt-get

reinstalling zmq (compile and do php bindings)

I don't have the latest php and apache, but at least the module is loaded both in Apache and in php CLI

Upvotes: 1

lxg
lxg

Reputation: 13107

I have to take a few guesses, but let's give it a try:

You appear to have different versions of PHP installed, or you have updated/downgraded your PHP.

You have the folder /usr/lib/php5/20100525/ on your system which belongs to PHP 5.4 on a Debian-type machine (I think). But your PHP looks for the file in /usr/lib/php5/20090626/, which I think belongs to PHP 5.3.

Your PHP CLI seems to run with PHP 5.4, while the mod_php of your Apache appears to run 5.3.

If this is true, you can try copying the zmq.so into /usr/lib/php5/20090626/zmq.so/ and restart Apache. But it could fail due to binary incompatibility, if it was built against PHP 5.4.

In this case, I'd recommend to upgrade your mod_php to PHP 5.4 (again?).

Upvotes: 2

Related Questions