How to install php-mongodb module for PHP 7 on CentOS 8


How to install PHP 7 on CentOS 8

Step 1: install php74-php-devel php74-php-pear

yum install -y php74-php-devel php74-php-pear

Step 2: install module mongodb
sudo /opt/remi/php74/root/usr/bin/pecl install mongodb

Result:

...
Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0" install
Installing shared extensions:     /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root/usr/lib64/php/modules/
running: find "/var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0" | xargs ls -dils
1578542    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0
1579085    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt
1579086    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi
1579087    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74
1579088    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root
1579089    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root/usr
1579090    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root/usr/lib64
1579091    4 drwxr-xr-x. 3 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root/usr/lib64/php
1579092    4 drwxr-xr-x. 2 root root    4096 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root/usr/lib64/php/modules
1579084 7668 -rwxr-xr-x. 1 root root 7852008 Oct  4 15:55 /var/tmp/pear-build-rootI520HD/install-mongodb-1.8.0/opt/remi/php74/root/usr/lib64/php/modules/mongodb.so

Build process completed successfully
Installing '/opt/remi/php74/root/usr/lib64/php/modules/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.8.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini

Step 3: create file /etc/opt/remi/php74/php.d/20-mongodb.ini

with content: extension=mongodb.so

echo extension=mongodb.so > /etc/opt/remi/php74/php.d/20-mongodb.ini

Step 4: restart php-fpm
service php74-php-fpm restart

Done, Verify:

[root@tutorialspots ~]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
intl
json
ldap
libxml
mbstring
mcrypt
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
recode
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

Recent search terms:

  • 2017 wso drwxr xr x php html

Leave a Reply