安静的竹子 發表於 2024-2-16 00:00:00

CentOS(x86_64)下PHP安装memcache扩展问题解决方法分享

<p>
        <span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>系统版本是5.2,把安装memcached的方法记录下先: </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        cd ~/memcached <br>
        wget -c http://www.monkey.org/~provos/libevent-1.4.10-stable.tar.gz <br>
        wget -c http://memcached.googlecode.com/files/memcached-1.2.8.tar.gz <br>
        #安装libevent <br>
        tar -zxvf libevent-1.4.10-stable.tar.gz <br>
        cd libevent-1.4.10-stable <br>
        ./configure <br>
        make <br>
        make install <br>
        #安装memcached <br>
        cd .. <br>
        tar -zxvf memcached-1.2.8.tar.gz <br>
        cd memcached-1.2.8 <br>
        ./configure <br>
        make <br>
        make install <br>
        #如果是64位系统,还需要把libevent的文件复制到/wp-content/lib64/下,用来解决error while loading shared libraries的问题 <br>
        cp -R /wp-content/local/lib/libevent* /wp-content/lib64/ </p>
<p>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        好了,开始安装php的扩展,恶梦开始了,本以为直接用yum来安装php-devel.x86_64和php-pecl-memcache.x86_64这两个扩展就可以了,可装了后 phpinfo()里根本找不到memcache扩展,把已经装的这两个扩展remove重来,还是不行,goooooooooooooogle,找到了一篇文章《PHP Pecl Memcached module installation problems》,有救喽,先remove掉php-pecl-memcache.x86_64,然后执行了</p>
<blockquote style='margin: 0px auto 10px; padding: 4px 4px 4px 10px; outline: none; background: rgb(244, 249, 251); border-left: 4px solid rgb(116, 205, 230); width: 665px; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
        <p>
                pecl install memcache</p>
</blockquote>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        顺利安装上了,打开/etc/php.d/看了下,没有memcache.ini,好吧,手动到/etc/php.ini加上了 extension=memcache.so,好了,重启httpd,刷新 phpinfo() ,竟然还没有,我郁闷了。。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        回头想想,我好像漏了一个地方没有检查,马上打开 /wp-content/lib64/php/modules/ 查看,果然没有memcache.so,会在哪呢? find -name之,原来躲在 /wp-content/local/lib/php/extensions/no-debug-non-zts-20060613/ 下,复制到 /wp-content/lib64/php/modules/ 再试,久违的 memcache扩展出现了。 T T</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS(x86_64)下PHP安装memcache扩展问题解决方法分享" alt="CentOS(x86_64)下PHP安装memcache扩展问题解决方法分享" class="alignnone size-medium wp-image-608" src="https://zhuji.jb51.net/uploads/img/202305/00a091523b2510efc1a01f9b0060722c.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>Memcached参数说明:</strong></p>
<ul style='margin: 0px 0px 0px 25px; padding: 0.3em 0px; outline: none; list-style: decimal; line-height: 25px; word-break: break-word; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
<li>
                <p>
                        -d选项是启动一个守护进程</p>
        </li>
        <li>
                <p>
                        -m分配给Memcache使用的内存数量,单位是MB</p>
        </li>
        <li>
                <p>
                        -u运行Memcache的用户</p>
        </li>
        <li>
                <p>
                        -l监听的服务器IP地址</p>
        </li>
        <li>
                <p>
                        -p设置Memcache监听的端口,最好是1024以上的端口</p>
        </li>
        <li>
                <p>
                        -c最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定</p>
        </li>
        <li>
                <p>
                        -P设置保存Memcache的pid文件</p>
        </li>
</ul>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>启动:</strong></p>
<blockquote style='margin: 0px auto 10px; padding: 4px 4px 4px 10px; outline: none; background: rgb(244, 249, 251); border-left: 4px solid rgb(116, 205, 230); width: 665px; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
        <p>
                memcached -d -u root -m 128 -c 8192</p>
</blockquote>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>查看状态:</strong></p>
<blockquote style='margin: 0px auto 10px; padding: 4px 4px 4px 10px; outline: none; background: rgb(244, 249, 251); border-left: 4px solid rgb(116, 205, 230); width: 665px; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
        <p>
                watch “echo stats | nc 127.0.0.1 11211″</p>
</blockquote>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS(x86_64)下PHP安装memcache扩展问题解决方法分享" alt="CentOS(x86_64)下PHP安装memcache扩展问题解决方法分享" class="alignnone size-full wp-image-609" src="https://zhuji.jb51.net/uploads/img/202305/792136b293f2a6d0c418db8cb4da3b55.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>状态说明:</strong></p>
<ul style='margin: 0px 0px 0px 25px; padding: 0.3em 0px; outline: none; list-style: decimal; line-height: 25px; word-break: break-word; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
<li>
                <p>
                        uptime:memcached运行的秒数</p>
        </li>
        <li>
                <p>
                        cmd_get:查询缓存的次数。这两个数据相除一下就能得到平均每秒请求缓存的次数</p>
        </li>
        <li>
                <p>
                         </p>
        </li>
        <li>
                <p>
                        cmd_set:设置key=&gt;value的次数</p>
        </li>
        <li>
                <p>
                        get_hits:缓存命中的次数。缓存命中率 = get_hits/cmd_get * 100%</p>
        </li>
        <li>
                <p>
                        scurr_items:现在在缓存中的键值对个数</p>
        </li>
</ul>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>相关网址:</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        Libevent:http://www.monkey.org/~provos/libevent/<br>
        Memcached:http://danga.com/memcached/<br>
        PHP Memcached Extension:http://pecl.php.net/package/memcache</p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'># pecl install memcache </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>downloading memcache-2.2.6.tgz ... </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Starting to download memcache-2.2.6.tgz (35,957 bytes) </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>..........done: 35,957 bytes </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11 source files, building </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>WARNING: php_bin /opt/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>running: phpize </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Configuring for: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>PHP Api Version: 20090626 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Zend Module Api No: 20090626 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Zend Extension Api No: 220090626 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Enable memcache session handler support? : n </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-memcache-2.2.6" install </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Installing shared extensions: /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions/no-debug-non-zts-20090626/ </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>running: find "/var/tmp/pear-build-root/install-memcache-2.2.6" | xargs ls -dils </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370548 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370602 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370603 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370604 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370605 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370606 4 drwxr-xr-x 3 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370607 4 drwxr-xr-x 2 root root 4096 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions/no-debug-non-zts-20090626 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>11370601 236 -rwxr-xr-x 1 root root 235639 Jan 6 15:55 /var/tmp/pear-build-root/install-memcache-2.2.6/opt/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Build process completed successfully </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>Installing '/opt/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so' </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>install ok: channel://pecl.php.net/memcache-2.2.6 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>configuration option "php_ini" is not set to php.ini location </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>You should add "extension=memcache.so" to php.ini </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'></span></p>
頁: [1]
查看完整版本: CentOS(x86_64)下PHP安装memcache扩展问题解决方法分享