【问题标题】:error when installing pecl memcached安装 pecl memcached 时出错
【发布时间】:2014-08-15 22:09:52
【问题描述】:

我在安装 pecl memcached 软件包时遇到了问题。

我没有对任何 yum 或 pear/pecl 安装命令感到满意我提到了这个问题 Install PECL Memcached Error 并开始尝试手动配置/制作

我正在使用 pecl 下载最新的 (memcached-2.2.0) 然后解压缩,phpize...

如果我使用 --disable-memcached-sasl 进行配置,则配置完成但 make 失败。看起来像语法错误

In file included from /root/memcached-2.2.0/php_memcached_private.h:28,
                 from /root/memcached-2.2.0/php_memcached.c:26:
/root/memcached-2.2.0/php_libmemcached_compat.h:56: error: expected ‘=’, ‘,’, ‘;’, ‘asm’     or ‘__attribute__’ before ‘php_memcached_instance_st’
/root/memcached-2.2.0/php_memcached.c:328: error: expected declaration specifiers or ‘...’ before ‘php_memcached_instance_st’
/root/memcached-2.2.0/php_memcached.c:329: error: expected declaration specifiers or     ‘...’ before ‘php_memcached_instance_st’
/root/memcached-2.2.0/php_memcached.c:330: error: expected declaration specifiers or ‘...’ before ‘php_memcached_instance_st’
/root/memcached-2.2.0/php_memcached.c: In function ‘php_memc_get_impl’:
/root/memcached-2.2.0/php_memcached.c:594: warning: passing argument 4 of     ‘memcached_mget_by_key’ from incompatible pointer type
/usr/include/libmemcached/memcached_get.h:38: note: expected ‘char **’ but argument is of type ‘const char **’
/root/memcached-2.2.0/php_memcached.c: In function ‘php_memc_getMulti_impl’:

还有更多,但希望这是一个足够有用的指标

如果我使用 --with-libmemcached-dir=/usr/include/libmemcached 我得到

checking for libmemcached location... configure: error: Unable to find memcached.h under /usr/include/libmemcached

但这就是 memcached.h 所在的地方

如果我使用 --with-libmemcached-dir=no 配置给出

configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check

如果我添加 --disable-memcached-sasl 选项,它配置完成但 make 再次失败并出现语法错误

感觉自己陷入了一个循环。

这不是我第一次从头开始设置服务器以使用 memcached(虽然我猜是一段时间以来的第一次)我不记得以前有任何问题。

有什么想法可以请任何人吗?

这看起来不错

http://blusmurf.net/2012/08/27/pecl-memcache-build-error/

但仍然没有快乐

我也一直在从 php-memcached 的 github 页面调查这个问题

https://github.com/php-memcached-dev/php-memcached/issues/69

我现在尝试使用 2.1 和 2.2,破解文件以尝试构建构建。还是没有运气...

【问题讨论】:

  • 我遇到了与 libmemcached 和 memcached.h 完全相同的问题。我正在研究它,如果我弄明白了,我会更新。如果您找到解决方案,请更新。
  • 我尝试安装 1.0.16 的 libmemcached 以与 php-memcached-2.1 一起使用,但在构建 libmemcached 时出错 ;-) 我仍在谷歌搜索和摆弄,生病让你知道。或者我会使用 redis :-D
  • 虽然我已经成功安装了 Memcached(你在构建 libmemcached 时遇到了什么错误?),即使我要使用 Redis - 在我的用例中,我想缓存对象,会话存储将是在不同的应用程序之间共享。 Memcached 不能用于 Session 存储(至少没有扭曲的方法),因此 redis 它是 \m/

标签: centos memcached pecl


【解决方案1】:

如果您不需要 SASL,请回答:

libmemcached 目录 [no] : no --disable-memcached-sasl

【讨论】:

  • 这成功了,没有任何漏洞,也不需要从源代码下载和编译特定的包或版本
【解决方案2】:

用这个组合解决了:

  1. libmemcached release 1.0.16 - 从源安装
  2. php-memcached release 2.1.0 - 从源安装并在 php.in 中添加 memcached.so

我希望这会有所帮助。

【讨论】:

  • 我没有尝试过这个,但我会相信你的话,以防有人发现这个,因为我读过的所有内容都表明它是正确的。只是我构建 libmemcached 的具体问题阻止了我进行测试
  • 是的,它有效。如果它对您不起作用,请检查您是否没有安装 libmemcached 1.1.16+ 而不是 libmemcached 1.0.16+。
【解决方案3】:

第 1 步 - 安装 SASL:

yum install cyrus-sasl-devel

第 2 步 - 编译安装了 SASL 的 libmemcached:

cd ~
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make && make install

第 3 步 - 安装 PHP Memcached:

pecl install memcached

(不要指定libmemcached-dir

【讨论】:

    【解决方案4】:

    如果您不需要 sasl 支持,这里是安装 2.2.X 的简单方法:

    pecl_memcached_ver="2.2.0"
    pecl download memcached-${pecl_memcached_ver}
    tar xzvf memcached-${pecl_memcached_ver}.tgz
    cd memcached-${pecl_memcached_ver}/
    phpize
    ./configure --disable-memcached-sasl
    make
    make install
    cd ..
    rm -r memcached-${pecl_memcached_ver}
    echo "extension=memcached.so" > /etc/php5/fpm/conf.d/20-memcached.ini
    

    然后运行php5 -i 测试它是否正确安装了2.2.x

    【讨论】:

      【解决方案5】:

      步骤:

      1. sudo apt-get install libmemcached libmemcached-dev
      2. sudo mkdir -p /usr/lib/x86_64-linux-gnu/include/libmemcached && sudo ln -s /usr/include/libmemcached/memcached.h /usr/lib/x86_64-linux-gnu/include/libmemcached /memcached.h
      3. echo "/usr/lib/x86_64-linux-gnu --disable-memcached-sasl" | sudo /opt/phpfarm/inst/php-5.4.40/bin/pecl -C /opt/phpfarm/inst/php-5.4.40/etc/pear.conf install memcached

      设置: Ubuntu 14.04.x LTS x64(值得信赖的 tahr) 带有pecl的phpfarm(最新) PHP 5.4.40 内存缓存 2.2.0

      注意:显然,您必须根据系统替换路径

      【讨论】:

        【解决方案6】:

        @rynop 的程序非常好,而且都很棒!

        现在你想打包部署怎么样?我的目标部署在 Ubuntu 14.04 LTS 上运行,我希望它将上游 php5-memcached 包替换为一个简单的 .deb 文件。

        为此,请使用look at fpm,它代表“Freaking Package Manager”(原文如此)。它可以用几乎任何东西创建包。

        在@rynop 程序之后,这是我所做的:

        // Rest of @rynop procedure, modulo this configure options
        ./configure --enable-memcached-igbinary --disable-memcached-sasl
        

        安装jordansissel/fpm

        apt-get install -y pkg-config ruby-dev gcc
        gem install fpm
        

        然后,检查您要替换的包内容,并为我们自己的目的进行复制。

        dpkg --list | grep php5-memcached
        find /var/cache/apt -type f -name '*php5-memcached*'
        dpkg -c /var/cache/apt/archives/php5-memcached_2.1.0-6build1_amd64.deb
        

        我在输出中发现我只需要几个文件夹,所以我创建了它们。

        mkdir -p etc/php5/mods-available/
        // Adjust memcached.ini to suit your tastes, then prepare it for packaging
        cp memcached.ini etc/php5/mods-available/
        // Make sure the usr/lib/php5/foo path matches in 
        // the result of `dpkg -c` you issued
        mkdir -p usr/lib/php5/20121212/
        cp modules/memcached.so usr/lib/php5/20121212/
        

        奇迹会发生

        fpm -s dir -t deb -n php5-memcached -v 2.2.0-wpd -m '<your@email.org>' --description 'PHP 5.5 PECL igbinary + memcached support' -d libmemcached10 etc/ usr/
        

        【讨论】:

          【解决方案7】:

          在安装了 libmemcached-devel 版本 1.0.16 的 CentOS 7.2 上,您应该使用 /usr 回答这个问题:

          libmemcached directory [no] : /usr

          【讨论】:

            猜你喜欢
            • 2014-04-01
            • 1970-01-01
            • 1970-01-01
            • 2019-02-08
            • 1970-01-01
            • 2017-05-23
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多