Centos中更新PHP版本

查看当前Centos版本:

cat /etc/centos-release

结果为:

CentOS release 6.3 (Final)

查看当前PHP版本:

php -v

结果为:

PHP 5.3.28 (cli) (built: Jun  6 2014 17:00:08) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

查看当前Apache版本:

httpd -v

结果为:

Server version: Apache/2.2.27 (Unix)
Server built:   Jun  6 2014 16:28:55

下载PHP7.1.12版本:http://php.net/downloads.php,然后进行解压缩:

gunzip php-7.0.26.tar.gz
tar -xf php-7.0.26.tar

进入解压文件中:

php-7.0.26

配置:

./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysqli --enable-mbstring --with-openssl --with-zlib --with-gd --with-jpeg-dir --with-freetype-dir

通过命令./configure --help可以查看所有的选项。
安装:

make
make install

以后如果想要更新配置,应该重新运行configure、make cleanmakemake install 步骤,然后重启apache。make clean步骤也很重要,不要忘记。

然后:

cp php.ini-development /usr/local/lib/php.ini

在httpd.conf文件(/etc/httpd/conf/httpd.conf)中添加:

LoadModule php7_module modules/libphp7.so

使httpd.conf加载PHP模块。这个语句可能在安装PHP时已经添加过了,如果没有的话,那么手动添加。

重启apache服务器:

service httpd restart

问题集锦

1、 Gd installed, but “Call to undefined function imagecreatefromjpeg()”?

解决:
查看phpinfo:
这里写图片描述
显然现在gd不支持jpeg。在配置时,需要加上--with-jpeg-dir,并且需要make clean,然后makemake installservice httpd restart
再次查看phpinfo:
这里写图片描述

问题解决。

参考

[1] Installation on Unix systems
[2] Gd installed, but “Call to undefined function imagecreatefromjpeg()“

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值