广告:宝塔Linux面板高效运维的服务器管理软件 点击【 https://www.bt.cn/p/uNLv1L 】立即购买
不知道你是否会安装PHP7,也不知道你是否会处理安装memcache扩展出现新旧php版本兼容问题,今天小编就带大家了解一下,有需要的可以参考参考。
http://php.net/downloads.php
安装php-7.0.0
首先安装依赖程序 如果已经安装过请略过
yum install -y php-mcrypt libmcrypt libmcrypt-develyum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel#openssl-devel是64位 如果是32位服务器请选择i386版的yum install openssl-devel.x86_64yum install curl curl-develyum -y install libxslt-develyum install -y php-mcrypt libmcrypt libmcrypt-devel mcrypt mhash登录后复制
./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--with-mcrypt \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--enable-fpm \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcachemake && make install可选--with-fpm-user=www \--with-fpm-group=www \登录后复制
如果提示configure: error: mcrypt.h not found. Please reinstall libmcrypt.
因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,由于版权的原因,只能借助第三方yum源,或者自己手动下载编译安装包
wget http://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz./configuremake && make install登录后复制
如果报checking for C++ compiler default output file name… configure: error: C++ compiler
cannot create executables
yum list | grep c++yum install gcc-c++.x86_64登录后复制
如果提示undefined reference to `libiconv’则需要先安装libiconv
--with-iconv=/usr/local/libiconv登录后复制
如果还是报错则vim Makefile
找到EXTRA_LIBS =
在最后面加上-liconv
或者直接make ZEND_EXTRA_LIBS=’-liconv’
如果重新安装的是旧版本的php则需要重新编译apache的LoadModule php5_module文件
./configure --with-apxs2=/usr/local/sbin/apxs登录后复制
此时php7安装完成
mv /usr/local/src/php-7.1.0/php.ini-production /usr/local/php7/etc/php.ini登录后复制
启用php-fpm服务
cd /usr/local/php7/etcmv php-fpm.conf.default php-fpm.confmv php-fpm.d/www.conf.default php-fpm.d/www.conf登录后复制
注意更改php-fpm.conf的user跟group否则可能会因为权限问题报File not found.
user = nobodygroup = nobody登录后复制
运行php-fpm
/usr/local/php7/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php7/etc/php-fpm.conf登录后复制
如果想使用此命令service php-fpm start|stop|restart
./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--with-mcrypt \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--enable-fpm \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcachemake && make install可选--with-fpm-user=www \--with-fpm-group=www \0登录后复制
就可以使用 sevice php-fpm start 来启用php-fpm了。用 ps -ef | grep php-fpm 看看进程吧。
但是当我安装memcache扩展的时候
http://pecl.php.net/package/memcache
安装memcache-2.2.7 2012年的稳定版
./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--with-mcrypt \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--enable-fpm \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcachemake && make install可选--with-fpm-user=www \--with-fpm-group=www \1登录后复制
此时报致命错误/root/memcache-2.2.7/memcache.c:40:40: fatal error: ext/standard/php_smart_str.h: No such file or directory
php_smart_str.h文件不存在
百度搜php_smart_string.h是给字符串预处理动态申请内存空间,类似于操作系统中内存以页为单位分配,它的好处是对齐内存地址,提高访问速度。
发现php7已经把此文件改成php_smart_string.h 对比看2个文件改动蛮大的
这个不知道是不是php官方开发组的兼容性没有做好 期待改善
推荐学习:php视频教程
以上就是如何安装php7及安装memcache扩展出现新旧php版本兼容问题该怎么办的详细内容,更多请关注9543建站博客其它相关文章!
发表评论