0

Centos下安装 PHP7.0.2

Posted by 撒得一地 on 2017年8月31日 in PHP笔记

PHP7 已经出来挺长一段时间了,不过还一直使用较低版本的 PHP。最近有一台闲置的 VPS,准备用来建一个简单的动态页面,便想尝试下 PHP7 的一些新特性。以下简单的记录下安装步骤。

安装前准备(安装编译工具及库文件)

	yum install make apr* autoconf automake curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd gettext gettext-devel kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel  libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch

安装前说明 : PHP7安装包存放路径 /usr/local/src , PHP7安装目录 /usr/local/php7

下载 PHP7 

	wget http://cn2.php.net/distributions/php-7.0.2.tar.gz

解压&进入目录

	tar -zxvf php-7.0.2.tar.gz

	cd php-7.0.2

生成 Makefile

	./configure --prefix=/usr/local/php7 --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo -enable-tokenizer --enable-zip

编译

	make

如果上面 make 出现如下错误: 

	cc: Internal error: Killed (program cc1)

	Please submit a full bug report.

	See <http://bugzilla.redhat.com/bugzilla> for instructions.

	make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

原因是内存不够,一般内存小的 VPS 可能碰到该问题,内存足够一般不会碰到该问题。解决方法是在 configure 时加上 –disable-fileinfo 参数(disable前面是两个 – ), 你需要重新执行 configure 操作,然后再进行 make 编译 。

如果 make 出现下面这中错误:

	collect2: ld returned 1 exit status

	make: *** [sapi/cli/php] Error 1

解决办法:

	make ZEND_EXTRA_LIBS='-liconv'

	ln -s /usr/local/lib/libiconv.so.2   /usr/lib64/

安装

	make install

操作配置文件

	cp /usr/local/src/php-7.0.2/php.ini-development  /usr/local/php7/lib/php.ini

	cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

	cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

	cp /usr/local/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

	chmod +x /etc/init.d/php-fpm

启动 php

	/etc/init.d/php-fpm start

本文地址 : https://coderschool.cn/2416.html

上一篇:

下一篇:

相关推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注

9 + 2 = ?

网站地图|XML地图

Copyright © 2015-2024 技术拉近你我! All rights reserved.
闽ICP备15015576号-1 版权所有©psz.