Php mongodb on centos8

Dear Community,

I've tried different methods of installing a php extension for MongoDB on my Centos server but this doesn't seem to work so far.

I'm using php 8.1 on Centos 8 Stream and normally I always use the same command. But it doesn't seem to work this time.

When running the following command: pecl install mongodb
The installation ends with the following lines.

... libtool: compile:  cc -I. -I/var/tmp/mongodb -I/var/tmp/pear-build-rootA0mHla/mongodb-1.10.0/include -I/var/tmp/pear-build-rootA0mHla/mongodb-1.10.0/main -I/var/tmp/mongodb -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/mongodb/src/libmongoc/src/common/ -I/var/tmp/mongodb/src/libmongoc/src/libbson/src/ -I/var/tmp/mongodb/src/libmongoc/src/libbson/src/jsonsl/ -I/var/tmp/mongodb/src/libmongoc/src/libmongoc/src/ -I/var/tmp/mongodb/src/libmongocrypt/src/ -I/var/tmp/mongodb/src/libmongocrypt/kms-message/src/ -I/var/tmp/mongodb/src/libmongocrypt-compat/ -I/var/tmp/mongodb/src/BSON/ -I/var/tmp/mongodb/src/MongoDB/ -I/var/tmp/mongodb/src/MongoDB/Exception/ -I/var/tmp/mongodb/src/MongoDB/Monitoring/ -I/var/tmp/mongodb/src/contrib/ -DHAVE_CONFIG_H -g -O2 -c /var/tmp/mongodb/src/MongoDB/BulkWrite.c -MMD -MF src/MongoDB/BulkWrite.dep -MT src/MongoDB/BulkWrite.lo  -fPIC -DPIC -o src/MongoDB/.libs/BulkWrite.o
In file included from /var/tmp/mongodb/src/MongoDB/BulkWrite.c:26:
/var/tmp/mongodb/src/MongoDB/BulkWrite.c: In function ‘php_phongo_bulkwrite_init_ce’:
/var/tmp/mongodb/php_phongo.h:174:21: error: ‘zend_class_serialize_deny’ undeclared (first use in this function); did you mean ‘zend_ce_serializable’?
   ce->serialize   = zend_class_serialize_deny;   \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/mongodb/src/MongoDB/BulkWrite.c:669:2: note: in expansion of macro ‘PHONGO_CE_DISABLE_SERIALIZATION’
  PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_bulkwrite_ce);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/mongodb/php_phongo.h:174:21: note: each undeclared identifier is reported only once for each function it appears in
   ce->serialize   = zend_class_serialize_deny;   \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/mongodb/src/MongoDB/BulkWrite.c:669:2: note: in expansion of macro ‘PHONGO_CE_DISABLE_SERIALIZATION’
  PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_bulkwrite_ce);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/mongodb/php_phongo.h:175:21: error: ‘zend_class_unserialize_deny’ undeclared (first use in this function); did you mean ‘zend_unserialize_data’?
   ce->unserialize = zend_class_unserialize_deny; \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/mongodb/src/MongoDB/BulkWrite.c:669:2: note: in expansion of macro ‘PHONGO_CE_DISABLE_SERIALIZATION’
  PHONGO_CE_DISABLE_SERIALIZATION(php_phongo_bulkwrite_ce);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:915: src/MongoDB/BulkWrite.lo] Error 1
ERROR: `make' failed

What exactly am I doing wrong? I have Selinux turned on but that would not be a problem with such an installation

Hi @Cherimos,

it seems that your PHP version is too new. Try to install php-8.0 & php-8.0-devel (maybe plus other modules) and uninstall php8-1*.

zend_class_serialize_deny is defined for 8.0 in zend_interfaces.h, which belongs to the php-devel package. I assume that php-8.1-devel is installed?

BTW, 8.1 is very new, it's only in RC1 stage, release is planned for 11/2021.

1 Like

Are you sure it is necessary to compile this?

Most of these extensions already exist in binary executable format for Linux.

I already suspected that this was the case, but when I retrieved a list of available modules, I saw the module mongodb version 8.1 (81) in between and that cleared my doubts.
But it turns out that it is indeed the version.

Thank you for your response and information.
Much appreciated.

1 Like

Usually it is not necessary indeed, but with this module it was unfortunately necessary.

Thank you for your message and response.