文章大纲

Linux下给php安装mongo插件,报main/php.h: No such file or directory错误

2022-09-29 11:30:00

今天在给php安装mongodb插件时,报/usr/local/include/php/main/php.h: No such file or directory错误。


[root@CN0015VMC02134 mongodb-1.14.1]# phpize
grep: /usr/local/include/php/main/php.h: No such file or directory
grep: /usr/local/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/local/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:

这是因为我们自定义安装的php位置跟默认不一致。

linux系统默认识别phpize命令,在/usr/bin、/usr/local/bin这些目录下,通过whereis命令可以查看到。


但我们自定义的phpize程序,就不在上面那些目录,自然所依赖的其它相关程序,也不在上面报错的那些位置。


当时我自定义安装php时,结束安装成功有显示各个部分安装的位置所在:

Installing shared extensions:     /usr/local/php7/lib/php/extensions/no-debug-non-zts-20200930/
Installing PHP CLI binary:        /usr/local/php7/bin/
Installing PHP CLI man page:      /usr/local/php7/php/man/man1/
Installing PHP FPM binary:        /usr/local/php7/sbin/
Installing PHP FPM defconfig:     /usr/local/php7/etc/
Installing PHP FPM man page:      /usr/local/php7/php/man/man8/
Installing PHP FPM status page:   /usr/local/php7/php/php/fpm/
Installing phpdbg binary:         /usr/local/php7/bin/
Installing phpdbg man page:       /usr/local/php7/php/man/man1/
Installing PHP CGI binary:        /usr/local/php7/bin/
Installing PHP CGI man page:      /usr/local/php7/php/man/man1/
Installing build environment:     /usr/local/php7/lib/php/build/
Installing header files:          /usr/local/php7/include/php/
Installing helper programs:       /usr/local/php7/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php7/php/man/man1/
  page: phpize.1
  page: php-config.1
/opt/software/php-8.0.23/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin/phar.phar
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers:           /usr/local/php7/include/php/ext/pdo/

所以从上面安装结果可以看出,我的phpize命令在/usr/local/php7/bin/这个位置。
我们就用这个位置的phpize去安装mongodb插件。

/usr/local/php7/bin/phpize
./configure --with-php-config= /usr/local/php7/bin/php-config
make && make install





我要评论
评论列表