热门IT资讯网

centos安装新PHP版本

发表于:2024-11-26 作者:热门IT资讯网编辑
编辑最后更新 2024年11月26日,方法一:yum 安装默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案:1.检查当前安装的PHP包yum list installed | grep php如果有安装的PHP包

方法一:

yum 安装

默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案:1.检查当前安装的PHP包yum list installed | grep php如果有安装的PHP包,先删除他们 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_642.Centos 5.X   rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm  CentOs 6.x  rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm  CentOs 7.X    rpm -Uvh                rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm如果想删除上面安装的包,重新安装rpm -qa | grep webstaticrpm -e  上面搜索到的包即可3.运行yum installyum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64注:如果想升级到5.6把上面的55w换成56w就可以了。yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_644.安装PHP FPMyum install php55w-fpm yum install php56w-fpm yum install php70w-fpm



方法二:

源码安装:

将之前的源码安装的版本备份为其他的名字mv /usr/local/php/ /usr/local/php5.3安装libiconv    mkdir -p /usr/local/setupcd /usr/local/setupwget tar zxvf libiconv-1.14.tar.gzcd libiconv-1.14./configure --prefix=/usr/local/libiconvmake && make installcd ..安装libmcrypt    wget tar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8./configuremake && make installcd ..安装mhash    tar jxvf mhash-0.9.3.tar.bz2cd mhash-0.9.3./configuremake && make installcd ..安装mcrypt    wget tar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8./configuremake && make installcd ..安装PHP 5.5.5    wget tar zxvf php-5.5.5.tar.gzcd php-5.5.5 正式编译,注意安装路径不能与旧版本路径相同     ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts make && make install


0