mongo.so:>未定义的符号:第0行上的Unknown中的php_json_encode.安装适用于php的mongo驱动程序后 [英] mongo.so: > undefined symbol: php_json_encode in Unknown on line 0. After installation mongo driver for php

查看:54
本文介绍了mongo.so:>未定义的符号:第0行上的Unknown中的php_json_encode.安装适用于php的mongo驱动程序后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

成功安装Mongo 2.6.0后,我尝试使用以下命令在ubuntu 12.04上升级php mongo驱动程序:sudo pecl upgrade mongo.它成功开始于:

After installation of Mongo 2.6.0 which was successful, I tried to upgrade php mongo driver on ubuntu 12.04 with the following command: sudo pecl upgrade mongo. It started successfully with:

downloading mongo-1.5.1.tgz ...
Starting to download mongo-1.5.1.tgz (188,885 bytes)
.........................................done: 188,885 bytes
117 source files, building
running: phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no]:

我选择No的位置,因为当我尝试是"时,它因错误而失败.没有,我无法成功安装它,结束消息看起来像这样:

Where I selected No because when I tried yes, it was failing with error. With no I was able to install it successufully and the ending message looked like this:

Build process completed successfully
Installing '/usr/lib/php5/20121212/mongo.so'
install ok: channel://pecl.php.net/mongo-1.5.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini

此后,我重新启动了Apache(2.4.9),但是我的phpinfo()告诉我未安装mongo.另一方面,我可以在php.ini中清楚地看到extension=mongo.so.

After this I restarted apache (2.4.9), but my phpinfo() told me that mongo is not installed. On the other hand I can clearly see extension=mongo.so in my php.ini.

我检查了我的error.log,在那里可以看到以下行:

I checked my error.log and I can see the following line there:

PHP警告:PHP启动:无法加载动态库 '/usr/lib/php5/20121212/mongo.so'-/usr/lib/php5/20121212/mongo.so: 未定义的符号:第0行的未知"中的php_json_encode

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/mongo.so' - /usr/lib/php5/20121212/mongo.so: undefined symbol: php_json_encode in Unknown on line 0

我检查了我的/usr/lib/php5/20121212/,发现实际上有一个文件mongo.so.我用谷歌搜索,唯一能够找到的类似内容是 ,这并不是很重要,但是由于没有其他选择,我仍然尝试在该步骤中没有成功.

I checked my /usr/lib/php5/20121212/ and saw that there is actually a file mongo.so. I googled it and the only similar thing I was able to find is this, which is not really relevant, but having no other options I still tried steps there with no success.

有人知道如何解决此问题吗?

Does anyone has an idea how to fix this?

推荐答案

问题与加载顺序有关,因此需要在加载mongo.so之前加载json扩展名.

The issue is with the loading order, so the json extension needs to be loaded before mongo.so is loaded.

由于其他人可能会遇到此问题,因此我将概述整个过程:

Since others are likely to come across this I will outline the whole process:

  • 在您的/etc/php/mods-available目录(或相应于平台)中,使用以下内容创建单独的mongo.ini:
  • In your /etc/php/mods-available directory (or as appropriate to platform) create a separate mongo.ini with the following:
; configuration for php mongo module
; priority=30
extension=mongo.so

  • 从其他文件(例如php.ini

    根据需要在每个cliapache2目录中创建符号链接,如下所示:

    Create symlinks in each of the cli and apache2 directories as required for use as so:

    sudo ln -s ../../mods-available/mongo.ini 30-mongo.ini

    在此之后,您应该具有一个类似于以下的结构

    At end of this you should have a structure that looks like this

    $/etc/php5$ tree
    .
    ├── apache2
    │   ├── conf.d
    │   │   ├── 05-opcache.ini -> ../../mods-available/opcache.ini
    │   │   ├── 10-pdo.ini -> ../../mods-available/pdo.ini
    │   │   ├── 20-json.ini -> ../../mods-available/json.ini
    │   │   ├── 20-readline.ini -> ../../mods-available/readline.ini
    │   │   └── 30-mongo.ini -> ../../mods-available/mongo.ini
    │   └── php.ini
    ├── cli
    │   ├── conf.d
    │   │   ├── 05-opcache.ini -> ../../mods-available/opcache.ini
    │   │   ├── 10-pdo.ini -> ../../mods-available/pdo.ini
    │   │   ├── 20-json.ini -> ../../mods-available/json.ini
    │   │   ├── 20-readline.ini -> ../../mods-available/readline.ini
    │   │   └── 30-mongo.ini -> ../../mods-available/mongo.ini
    │   └── php.ini
    └── mods-available
        ├── json.ini
        ├── mongo.ini
        ├── opcache.ini
        ├── pdo.ini
        └── readline.ini
    

    这可以确保在"mongo"模块之前由动态加载程序加载"json"扩展名.

    This makes sure that the "json" extension will be loaded by the dynamic loader before the "mongo" module is.

    但是基本上从中删除mongo.so并将其放入具有比json扩展名更高的加载顺序的它自己的文件中.然后它将起作用.

    But basically remove the mongo.so from "php.ini" and put it in it's own file with higher loading order than the json extension. Then it will work.

    这可能需要一个JIRA,因为我相信它已经出现过.

    This possibly needs a JIRA as I believe it has come up before.

    更新:实际上是一个开放的JIRA PHP-1052

    UPDATE: Actually is an open JIRA PHP-1052

    这篇关于mongo.so:>未定义的符号:第0行上的Unknown中的php_json_encode.安装适用于php的mongo驱动程序后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆