centos6.6上 nginx+php5.3将php版本升级php5.6

2025-10-31 14:42:50

1、到php官网下载php-5.6.28.tar.gz,用ftp或者ssh工具将下载好的安装包上传到Linux服务器上。

centos6.6上 nginx+php5.3将php版本升级php5.6

2、卸载php5.3版本,linux上只要将对应php安装目录删除即可。

rm /usr/local/php -fr    (为什是/usr/local/php这个目录,这由php的安装目录而定)

centos6.6上 nginx+php5.3将php版本升级php5.6

3、解压php-5.6.28.tar.gz。

解压命令:tar -zxvf  php-5.6.28.tar.gz

解压完之后,会生成php-5.6.28目录

centos6.6上 nginx+php5.3将php版本升级php5.6

centos6.6上 nginx+php5.3将php版本升级php5.6

4、进入解压后的目录。

cd  php-5.6.28

进入目录后,执行

./configure --prefix=/usr/local/php  #指定php安装的目录

--with-mysql=mysqlnd 

--with-pdo-mysql=mysqlnd

--with-mysqli=mysqlnd 

--with-freetype-dir=/usr/local/freetype  #指定freetype的路径,由freetype安装的真实路径定

--with-gd=/usr/local/gd  #指定gd的路径,由gd安装的真实路径定

--with-zlib 

--with-libxml-dir=/usr/local/libxml2 #指定libxml2的路径,由libxml2安装的真实路径定

--with-jpeg-dir=/usr/local/jpeg #指定jpeg的路径,由jpeg安装的真实路径定

--with-png-dir=/usr/local/png #指定png的路径,由png安装的真实路径定

--enable-mbstring=all 

--enable-mbregex 

--enable-shared 

--with-openssl-dir=/usr/local/openssl #指定openssl的路径,由openssl安装的真实路径定

--with-openssl 

--enable-fpm 

--with-config-file-path=/usr/local/php/etc #指定php的配置文件路径

--with-curlwrappers

centos6.6上 nginx+php5.3将php版本升级php5.6

centos6.6上 nginx+php5.3将php版本升级php5.6

5、编译安装。

make && make install

centos6.6上 nginx+php5.3将php版本升级php5.6

6、查看安装php版本是否升级成功。

php -v 

centos6.6上 nginx+php5.3将php版本升级php5.6

1、若在安装php5.6时,执行./configure 时出现错误gd库版本低的问题,只要下载高版本的gd库安装就行了。我系统当时的gd库版本是2.0的,所以我下载了libgd-2.1.0.tar.gz。

centos6.6上 nginx+php5.3将php版本升级php5.6

2、解压libgd-2.1.0.tar.gz

tar -zxvf libgd-2.1.0.tar.gz

进入目录

cd libgd-2.1.0

执行

./configure --prefix=/usr/local/gd  --with-jpeg=/usr/local/jpeg/  --with-png=/usr/local/png --with-zlib --with-freetype=/usr/local/freetype

centos6.6上 nginx+php5.3将php版本升级php5.6

centos6.6上 nginx+php5.3将php版本升级php5.6

3、Xpm library选项必须为yes,若为no,在编译php5.6版本会出现

X11/xpm.h: No such file or directory的错误。Xpm library选项为no是因为没有安装libXpm-devel。

安装libXpm-devel,执行yum -y install libXpm-devel

centos6.6上 nginx+php5.3将php版本升级php5.6

centos6.6上 nginx+php5.3将php版本升级php5.6

4、安装libXpm-devel,再重新执行步骤的./configure命令。

这时Xpm library选项为yes,如图。

centos6.6上 nginx+php5.3将php版本升级php5.6

5、编译安装

make && make install

升级好gd版本之后,再返回去编译安装php

centos6.6上 nginx+php5.3将php版本升级php5.6

6、可能会出现依赖库版本的问题,这每个系统的环境不一样,所以出现的依赖版本的问题也不一样。但是也不用害怕,一般出错都有相应的提示的,跟着提示去解决就好了。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢