查看当前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 clean
、make
、make 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
,然后make
,make install
,service httpd restart
。
再次查看phpinfo:
问题解决。
参考
[1] Installation on Unix systems
[2] Gd installed, but “Call to undefined function imagecreatefromjpeg()“