在CentOS上使用PHP 7的Memcache扩展无法安装 [英] Memcache extension with PHP 7 on CentOS fails to install
问题描述
我正在尝试将相当大的PHP 5.3代码库升级到PHP7.它托管在CentOS 6.5上,因此我希望将其保留在该OS上.我目前正在原始的Vagrant机器上进行此操作-我已经成功安装了PHP 7,并且安装了除Memcache之外的所有模块.
I'm trying to upgrade a fairly large PHP 5.3 code base to PHP 7. It's hosted on CentOS 6.5, so I want to keep it on that OS. I'm currently doing it on a virgin Vagrant box - I've installed PHP 7 successfully, and all the modules except for Memcache.
以根用户身份,当我运行pecl install memcache
时,它将尝试安装v2.2.7,但是我从 make 中获得了很多错误和警告.最后是:
As root, when I run pecl install memcache
it tries to install v2.2.7 but I get a long list of errors and warnings from make. At the end is:
make: *** [memcache.lo] Error 1
ERROR: `make' failed
根据 GoPHP7 ,它应该可以工作,Memcache应该可以与PHP一起工作7-它显示" github上的php7端口".确实在GitHub上有一个 Memcache PHP 7端口.当我在Pecl页面上查看 Memcache页面时,它表明我应该安装v3.0.8. ,但仍处于测试阶段(自2013年以来).
According to GoPHP7 it should work, Memcache should work with PHP 7 - it says "php7 port on github". There is indeed a Memcache PHP 7 port on GitHub. When I look at the Memcache page on Pecl page, it shows that I should be installing v3.0.8, but this in beta (and has been since 2013).
所以我尝试运行pecl install memcache-3.0.8
,但它仍然失败,并出现与上述相同的错误:
So I try to run pecl install memcache-3.0.8
and it still fails, with the same error as above:
make: *** [memcache.lo] Error 1
ERROR: `make' failed
那么能否在CentOS 6.5上使Memcache扩展与PHP 7一起使用?
So is it possible to get the Memcache extension working with PHP 7 on CentOS 6.5?
推荐答案
如果您尚未解决此问题,那么我有一个适合我的解决方案.我使用的是CentOS 7.x,但它仍然可以为您工作,并且其他任何想要与 pecl-memcache 一起使用的人PHP 7(不是 pecl-memcached ,因为这是一个完全不同的软件包).
If you haven't solved this yet, I have a solution that worked for me. I'm on CentOS 7.x but it should still work for you, and anyone else wanting to use pecl-memcache with PHP 7 (not pecl-memcached as that's a completely different package).
您已经发现,必须为此使用 GitHub上的Memcache PHP 7端口.
As you have already discovered, you must use the Memcache PHP 7 port on GitHub for this.
登录您的Shell并执行以下操作:
Login to your shell and perform the following:
1. wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
2. unzip NON_BLOCKING_IO_php7.zip
3. cd pecl-memcache-NON_BLOCKING_IO_php7
4. /opt/cpanel/ea-php70/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config && make
5. cp modules/memcache.so /opt/cpanel/ea-php70/root/usr/lib64/php/modules/
6. echo 'extension=memcache.so' >/opt/cpanel/ea-php70/root/etc/php.d/memcached.ini
7. service httpd restart
上述注意事项
- 将您使用的每个完整路径替换为您自己系统上的相应完整路径.当我拥有/opt/cpanel/ea-php70/root/时,您可能拥有/opt/php-7.0.7/.如果像我一样安装了多个PHP版本,则运行phpize可能最终会使用旧版本的PHP进行构建.经过反复试验,我发现了这一点.
- 要找出您的PHP modules文件夹在哪里,可以运行"/opt/cpanel/ea-php70/root/usr/bin/php -i | grep extension_dir"
- 如果您已经在其他地方加载了memcached.ini,则可能不需要执行步骤6.
- 您可以使用"/opt/cpanel/ea-php70/root/usr/bin/php -i | grep memcache"来验证其是否正确构建和安装.如果您看到各种内存缓存条目,则说明一切都已成功安装.
- Replace each full path that I've used with the appropriate full path on your own system. While I have /opt/cpanel/ea-php70/root/, you may have /opt/php-7.0.7/. If you have multiple PHP versions installed, as I do, running phpize may end up building using an old version of PHP. I discovered this after much trial and error.
- To find out where your PHP modules folder is, you can run "/opt/cpanel/ea-php70/root/usr/bin/php -i | grep extension_dir"
- You may not need to perform step 6 where I am creating a memcached.ini if you already have it loaded elsewhere.
- You can verify if it was correctly built and installed using "/opt/cpanel/ea-php70/root/usr/bin/php -i | grep memcache". If you see various memcache entries, everything was installed successfully.
希望对您有帮助!
这篇关于在CentOS上使用PHP 7的Memcache扩展无法安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!