您的位置:首页 > 数据库 > Redis

PHP安装扩展原理+php7的redis扩展安装

2017-06-05 19:12 357 查看
前言:安装拓展其实就是用php去编译一个扩展文件格式成.dll,放到php指定的路径下面,配置php.ini,这样php就能引用安装(fastcgi模式)的时候,常常有这样一句命令:/usr/local/webserver/php/bin/phpize一、phpize是干嘛的? phpize是什么东西呢?php官方的说明:
http://php.net/manual/en/install.pecl.phpize.php
phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块比如你想在原来编译好的php中加入memcached或者ImageMagick等扩展模块,可以使用phpize,通过以下几步工作。 二、如何使用phpize? 当php编译完成后,php的bin目录下会有phpize这个脚本文件。在编译你要添加的扩展模块之前,执行以下phpize就可以了;比如现在想在php中加入memcache扩展模块:我们要做的只是如下几步————————————————————————tar zxvf memcache-2.2.5.tgzcd memcache-2.2.5//usr/local/webserver/php/bin/phpize./configure –with-php-config=/usr/local/webserver/php/bin/php-configmakemake install———————————————————————— 注意./configure 后面可以指定的是php-config文件的路径这样编译就完成了,还需要做的是在php.ini文件中加入extension值extension = “memcache.so”---------------------------------------------------------注意:Cannot find config.m4.这个错误是一个很傻的错误,解压以后需要cd到文件夹,不然phpize就会报错Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.很明显缺少文件,需要安装。网上找了下资料。7.0php扩展遇到的问题-----------------------------------------------------------------------分割线-----------------------------------------------------------------------------------下面则是php的扩展memcache安装了。用之前的php版本安装是没有问题,但是用了php7安装 http://pecl.php.net/package/memcache 下的任一款memcache都会报错穷尽一切办法之后发现了 Github的pecl-memcache分支版本本地下载,https://github.com/websupport-sk/pecl-memcache/archive/php7.zip1. rz命令 上传至linux虚拟机上。
unzip pecl-memcache-php7.zip
cd pecl-memcache-php7
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
2. 修改php.ini 加载Memcache组件
[memcache]
extension_dir = "/usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/"
extension = "memcache.so"
注!!!一定要确认有效的 php.ini的位置也可以直接yum安装# wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
# tar -zvxf m4-1.4.9.tar.gz# cd m4-1.4.9/# ./configure && make && make install# cd ../# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar -zvxf autoconf-2.62.tar.gz# cd autoconf-2.62/# ./configure && make && make install然后执行以下命令进行安装#/usr/local/php/bin/phpize#./configure –prefix=/usr/local/memcached –with-libevent=/usr/local/libevent –with-php-config=/usr/local/php/bin/php-config#make && make install动态编译PHP的memcache扩展库,在执行/usr/localphp/bin/phpize时出现了错误,========================redis部分华丽分割线=========================PHP7.0.0正式版发布有一段时间了,但是与之对应的扩展组件非常之少,特别是windows上用PHP7搭建开发平台,组件太少肯定是影响开发的。目前PHP官网的PECL上日常用到的大部分PHP扩展组件都没有适配PHP7的,这源于PHP7的一些新特性与依赖关系和PHP5有很多不同之处,所以很多组件都需要开发者们经过一段时间的开发以适配PHP7。PHP官方库里没有PHP7的redis扩展:https://pecl.php.net/package/redis编译安装下载github地址:https://github.com/phpredis/phpredis/tree/php7Windows:https://github.com/neil-chen/NeilChen/tree/master/php_redis注: php7目录下有php7.dll的选择nts版本;有php7ts.dll的选择ts版本。Linux安装:cd phpredis/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake install上面的操作完成后,会在/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626目录下生成出一个redis.so文件,下面我们需要把这个so文件加到php.ini中vi /usr/local/php/etc/php.ini具体设置如下:extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"extension=redis.so原贴地址:http://php.upupw.net/news/4/5305.html========================mongodb部分华丽分割线=========================php7.0以上都用mongodb,mongo已经被弃用,具体区别百度安装过程遇到不少坑,mac下面一定不要brew instll,会升级其他版本带来错误还是自己解决下载7.0适用的mongodb安装包,亲试过,不过下载链接地方要翻墙 http://www.jianshu.com/p/c628bfa4b243


解决Mac OS编译安装时出现 cannot find openssl's <evp.h> 错误的问题 https://segmentfault.com/a/1190000007112520

2、下载源代码包后,在终端进入源码目录,执行下面的命令进行编译和安装
注意:要严格指定openssl的路径
cd mongodb

phpize

./configure --with-openssl-dir = /usr/local/Cellar/openssl/1.0.2j

make

sudo make install


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: