2015年6月11日,PHP官网发布消息,正式公开发布PHP7第一版的alpha版本.
PHP7特性:
PHP 7.0.0 Alpha 1使用新版的ZendEngine引擎,带来了许多新的特性,以下是不完全列表:
(1)性能提升:PHP7比PHP5.6性能提升了两倍。 Improved performance: PHP 7 is up to twice as fast as PHP 5.6
(2)全面一致的64位支持。 Consistent 64-bit support
(3)以前的许多致命错误,现在改成抛出异常。Many fatal errors are now Exceptions
(4)移除了一些老的不在支持的SAPI(服务器端应用编程端口)和扩展。Removal of old and unsupported SAPIs and extensions
(5)新增了空接合操作符。The null coalescing operator (??)
(6)新增加了结合比较运算符。Combined comparison Operator (<=>)
(7)新增加了函数的返回类型声明。Return Type Declarations
(8)新增加了标量类型声明。Scalar Type Declarations
(9)新增加匿名类。Anonymous Classes
PHP7安装笔记整理
# 安装mcrypt
PHP;">
yum install -y PHP-mcrypt libmcrypt libmcrypt-devel
# 升级bison
PHP;">
cd /var/soft/
wget http://ftp.gnu.org/gnu/bison/bison-2.6.4.tar.gz
tar -xvzf bison-2.6.4.tar.gz
cd bison-2.6.4
./configure
make && make install
# 升级re2c,解决You will need re2c 0.13.4 or later if you want to regenerate PHP
parsers.错误
PHP;">
cd /var/soft/
wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
tar zxf re2c-0.13.5.tar.gz && cd re2c-0.13.5
./configure
make && make install
编译PHP7
PHP;">
# 创建目录
mkdir -p /var/soft/PHP7
cd /var/soft/PHP7
# 下载源代码
git clone http://git.PHP.net/repository/PHP-src.git
cd PHP-src
./buildconf
# 配置参数
./configure --prefix=/usr/local/PHP7 \
--with-config-file-path=/usr/local/PHP7/etc \
--with-mcrypt=/usr/include \
--with-MysqL=MysqLnd \
--with-MysqLi=MysqLnd \
--with-pdo-MysqL=MysqLnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
#################################################################################
# 编译安装PHP时出现 /encodings.c:101: undefined reference to `libiconv_close' 错误的解决方法
# 在装PHP时出现以下的错误:
# /root/Downloads/PHP-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open'
# /root/Downloads/PHP-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv'
# /root/Downloads/PHP-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
# /root/Downloads/PHP-5.6.5/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
# collect2: error: ld returned 1 exit status
# make: *** [sapi/cli/PHP] Error 1
# 根据PHP官网描述这是一个bug(https://bugs.PHP.net/bug.PHP?id=52611)。在configure以后要手动修改下Makefile文件,找到EXTRA_LIBS 在最后添加 -liconv 即可顺利通过
# (大约在Makefile文件的104)
# EXTRA_LIBS = -lcrypt -lz -lresolv -lcrypt -lrt -lMysqLclient -lmcrypt -lltdl -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lcurl -lxml2 -lz -lm -ldl -lfreetype -lMysqLclient -lz -lm -lssl -lcrypto -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lssl -lcrypto -lcrypt -liconv
#################################################################################
# 编译安装
make && sudo make install
# 配置
PHP;">
cp PHP.ini-production /usr/local/PHP7/etc/PHP.ini
cp sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP7-fpm
chmod +x /etc/init.d/PHP7-fpm
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
# 配置opcache
PHP;">
vim /usr/local/PHP7/etc/PHP.ini
# 加入
zend_extension=/usr/local/PHP7/lib/PHP/extensions/no-debug-non-zts-20141001/opcache.so
# 启动
/etc/init.d/PHP7-fpm start