8

I've tried two different ways to install the mongodb php driver.

The server is Centos 6.6 (32-bit) that was originally a 6.5 virtualbox image that (following an update) now calls itself 6.6

The error seems to start here:

In file included from /var/tmp/mongo/io_stream.c:34:
/var/tmp/mongo/contrib/php-ssl.h:33:25: error: openssl/evp.h: No such file or directory
/var/tmp/mongo/contrib/php-ssl.h:34:26: error: openssl/x509.h: No such file or directory
/var/tmp/mongo/contrib/php-ssl.h:35:28: error: openssl/x509v3.h: No such file or directory
In file included from /var/tmp/mongo/io_stream.c:34:
/var/tmp/mongo/contrib/php-ssl.h:38: error: expected ‘)’ before ‘*’ token
/var/tmp/mongo/contrib/php-ssl.h:39: error: expected ‘)’ before ‘*’ token
/var/tmp/mongo/contrib/php-ssl.h:40: error: expected ‘)’ before ‘*’ token
/var/tmp/mongo/io_stream.c: In function ‘php_mongo_io_stream_connect’:
/var/tmp/mongo/io_stream.c:189: error: ‘X509’ undeclared (first use in this function)
/var/tmp/mongo/io_stream.c:189: error: (Each undeclared identifier is reported only once
/var/tmp/mongo/io_stream.c:189: error: for each function it appears in.)
/var/tmp/mongo/io_stream.c:189: error: ‘cert’ undeclared (first use in this function)
/var/tmp/mongo/io_stream.c:194: error: expected expression before ‘)’ token
make: *** [io_stream.lo] Error 1
ERROR: `make' failed

-other items of note:

php -v
PHP 5.6.6 (cli) (built: Feb 19 2015 10:19:59)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

mongo --version
MongoDB shell version: 2.6.8
openssl is installed 1.0.1e-30.e16_6_6.5.i686

I've checked other (seemingly related) Stack posts, such as MongoDB PHP driver can't installed Centos 6 cloud server - but it didn't seem to help or apply. Any ideas? Thanks.

Community
  • 1
  • 1
Adam T
  • 675
  • 8
  • 22

2 Answers2

36

Looks like you don't have the headers installed for OpenSSL.

Try yum install openssl-devel (or use sudo if not root) then recompile.

BA_Webimax
  • 2,714
  • 1
  • 13
  • 15
  • 1
    thanks that did the trick. I did not have openssl-devel installed. Afterwards... I got this, Build process completed successfully Installing '/usr/lib/php/modules/mongo.so' You should add "extension=mongo.so" to php.ini ...Of course line breaks don't show up in comments. But yes, it did install the driver and place it in the proper directory. Cheers! – Adam T Mar 16 '15 at 18:00
  • It didn't solve my problem, All the packages in this response and the other responses are installed, any idea? – Nayef Jun 13 '17 at 10:51
  • I have installed cyrus-sasl-devel and it resolves the error. I used this answer: https://stackoverflow.com/a/26328099/559720 – Nayef Jun 13 '17 at 11:02
2

For anyone the command yum install openssl-devel did not solve Installing PHP56 Mongo Driver in centos instance try to use/install these first

sudo yum install php-pear

sudo yum install php56-devel

sudo yum install gcc

sudo yum install openssl-devel

sudo pecl install mongodb
Raj Nandan Sharma
  • 3,694
  • 3
  • 32
  • 42