阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0

101次阅读
没有评论

共计 5789 个字符,预计需要花费 15 分钟才能阅读完成。

PHP 是一种为我们熟知的通用服务器网页脚本语言。非常多的在线网站都是用 PHP 编写的。PHP 这些年来一直在持续进化,丰富其功能,变得易于使用,更好地组织的脚本语言。目前 PHP 的开发团队正筹备下一个 PHP 版本的发行,名字是 PHP 7。现在的 PHP 版本为 PHP 5.6,可能你清楚 PHP 6 已经流产了,PHP 7 的支持者们不希望下一个重要的版本被其他分支混淆,即过去已经停止很久的 PHP 6。所以决定下一个 PHP 主要的发行版本叫 PHP 7,而不是 PHP 6。PHP 7.0 预计在今年十一月份发行。

在下一代主要 PHP 版本里有一些不错的功能:

  • 为了改善执行效率与内存占用,新的版本添加了 PHPNG 功能。
  • 引入了 JIT 引擎来动态编译 Zend 操作码为自然机器码,以此来达到更快的处理性能。这项功能允许随后的程序调用同一份代码,这样会运行快很多。
  • AST(抽象语法树)是最新添加的功能,它可以增强支持 PHP 的扩展性和用户应用。
  • 添加异步编程功能以支持同一个请求中的并行任务。
  • 新的版本会支持独立的多线程网页服务器,这样可以使用一个单独的存储池处理很多并发的请求。

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0

 

在 CentOS/Fedora 上安装 PHP 7

让我们来看看怎样在 CentOS 7 和 Fedora 21 安装 PHP7。为了安装 PHP7,我们首先需要克隆 php-src 仓库。当克隆工作完成,我们再配置和编译它。进行下一步之前,我们要确保已经在 LInux 系统下安装了如下的组件,否则 PHP 编译会返回错误中止。

  • Git
  • autoconf
  • gcc
  • bison

所有上面提到的要求可以使用 Yum 软件包管理器安装。以下一条命令即可完成:

  1. yum install git autoconf gcc bison

准备好开始安装 PHP7 了吗?让我们先创建一个 PHP7 目录,作为你的当前工作目录。

  1. mkdir php7
  2. cd php7

现在克隆 php-src 仓库,在终端里运行下面的命令。

  1. git clone https://git.php.net/repository/php-src.git

工作应该会在几分钟后完成,这里是一个样例输出,你应该会在任务完成时看见。

  1. [root@localhost php7]# git clone https://git.php.net/repository/php-src.git
  2. Cloninginto'php-src'...
  3. remote:Counting objects:615064,done.
  4. remote:Compressing objects:100%(127800/127800),done.
  5. remote:Total615064(delta 492063), reused 608718(delta 485944)
  6. Receiving objects:100%(615064/615064),152.32MiB|16.97MiB/s,done.
  7. Resolving deltas:100%(492063/492063),done.

让我们来配置,编译 PHP7,在终端运行下面的命令,开始配置工作:

  1. cd php-src
  2. ./buildconf

下面是./buildconf 命令的样例输出。

  1. [root@localhost php-src]#./buildconf
  2. buildconf: checking installation...
  3. buildconf: autoconf version 2.69(ok)
  4. rebuilding aclocal.m4
  5. rebuilding configure
  6. rebuilding main/php_config.h.in

使用下面的命令,继续配置进程:

  1. ./configure \
  2. --prefix=$HOME/php7/usr \
  3. --with-config-file-path=$HOME/php7/usr/etc \
  4. --enable-mbstring \
  5. --enable-zip \
  6. --enable-bcmath \
  7. --enable-pcntl \
  8. --enable-ftp \
  9. --enable-exif \
  10. --enable-calendar \
  11. --enable-sysvmsg \
  12. --enable-sysvsem \
  13. --enable-sysvshm \
  14. --enable-wddx \
  15. --with-curl \
  16. --with-mcrypt \
  17. --with-iconv \
  18. --with-gmp \
  19. --with-pspell \
  20. --with-gd \
  21. --with-jpeg-dir=/usr \
  22. --with-png-dir=/usr \
  23. --with-zlib-dir=/usr \
  24. --with-xpm-dir=/usr \
  25. --with-freetype-dir=/usr \
  26. --with-t1lib=/usr \
  27. --enable-gd-native-ttf \
  28. --enable-gd-jis-conv \
  29. --with-openssl \
  30. --with-mysql=/usr \
  31. --with-pdo-mysql=/usr \
  32. --with-gettext=/usr \
  33. --with-zlib=/usr \
  34. --with-bz2=/usr \
  35. --with-recode=/usr \
  36. --with-mysqli=/usr/bin/mysql_config

这会花去不少的时间,当完成后你应该会看到如下面的输出:

  1. creating libtool
  2. appending configuration tag "CXX" to libtool
  3. Generating files
  4. configure: creating ./config.status
  5. creating main/internal_functions.c
  6. creating main/internal_functions_cli.c
  7. +--------------------------------------------------------------------+
  8. |License:|
  9. |This software is subject to the PHP License, available inthis|
  10. | distribution in the file LICENSE.By continuing this installation |
  11. | process, you are bound by the terms of this license agreement.|
  12. |If you donot agree with the terms of this license, you must abort |
  13. | the installation process at this point.|
  14. +--------------------------------------------------------------------+
  15. Thank you forusing PHP.
  16. config.status: creating php7.spec
  17. config.status: creating main/build-defs.h
  18. config.status: creating scripts/phpize
  19. config.status: creating scripts/man1/phpize.1
  20. config.status: creating scripts/php-config
  21. config.status: creating scripts/man1/php-config.1
  22. config.status: creating sapi/cli/php.1
  23. config.status: creating sapi/cgi/php-cgi.1
  24. config.status: creating ext/phar/phar.1
  25. config.status: creating ext/phar/phar.phar.1
  26. config.status: creating main/php_config.h
  27. config.status: executing default commands

运行下面的命令,完成编译过程。

  1. make

“make”命令的样例输出如下所示:

  1. Generating phar.php
  2. Generating phar.phar
  3. PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
  4. clicommand.inc
  5. directorytreeiterator.inc
  6. directorygraphiterator.inc
  7. pharcommand.inc
  8. invertedregexiterator.inc
  9. phar.inc
  10. Build complete.
  11. Don't forget to run 'make test'.

活儿干完了,该安装 PHP7 了,运行下面的命令安装它。

  1. make install

成功安装的进程的样例输出应该像这样:

  1. [root@localhost php-src]# make install
  2. Installing shared extensions:/root/php7/usr/lib/php/extensions/no-debug-non-zts-20141001/
  3. Installing PHP CLI binary:/root/php7/usr/bin/
  4. Installing PHP CLI man page:/root/php7/usr/php/man/man1/
  5. Installing PHP CGI binary:/root/php7/usr/bin/
  6. Installing PHP CGI man page:/root/php7/usr/php/man/man1/
  7. Installing build environment:/root/php7/usr/lib/php/build/
  8. Installing header files:/root/php7/usr/include/php/
  9. Installing helper programs:/root/php7/usr/bin/
  10. program: phpize
  11. program: php-config
  12. Installing man pages:/root/php7/usr/php/man/man1/
  13. page: phpize.1
  14. page: php-config.1
  15. Installing PEAR environment:/root/php7/usr/lib/php/
  16. [PEAR]Archive_Tar- installed:1.3.13
  17. [PEAR]Console_Getopt- installed:1.3.1
  18. [PEAR]Structures_Graph- installed:1.0.4
  19. [PEAR] XML_Util - installed:1.2.3
  20. [PEAR] PEAR - installed:1.9.5
  21. Wrote PEAR system config file at:/root/php7/usr/etc/pear.conf
  22. You may want to add:/root/php7/usr/lib/php to your php.ini include_path
  23. /root/php7/php-src/build/shtool install -c ext/phar/phar.phar /root/php7/usr/bin
  24. ln -s -f /root/php7/usr/bin/phar.phar /root/php7/usr/bin/phar
  25. Installing PDO headers:/root/php7/usr/include/php/ext/pdo/

恭喜你,PHP7 已经安装在你的 Linux 系统上了。安装完后,进入 PHP7 安装文件里的 sapi/cli 里面。

  1. cd sapi/cli

验证一下 PHP 的版本。

  1. [root@localhost cli]#./php -v
  2. PHP 7.0.0-dev (cli)(built:Mar28201500:54:11)
  3. Copyright(c)1997-2015The PHP Group
  4. ZendEngine v3.0.0-dev,Copyright(c)1998-2015ZendTechnologies

 

总结

PHP 7 也添加到了 remi 仓库,这个即将到来的版本主要关注执行效率的提升,它的新特性致力于使 PHP 较好满足现代编程的需求和趋势。PHP 7.0 将会有许多新的特性、丢弃一些老版本的东西。在接下来的日子里,我们希望看到新特性和弃用功能的具体情况。希望你喜欢!

CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm

在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm

Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm

《细说 PHP》高清扫描 PDF+ 光盘源码 + 全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm

CentOS 6 中配置 PHP 的 LNMP 的开发环境  http://www.linuxidc.com/Linux/2013-12/93869.htm

PHP 的详细介绍 :请点这里
PHP 的下载地址 :请点这里

更多 Fedora 相关信息见 Fedora 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=5

更多 CentOS 相关信息见 CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14


via: http://linoxide.com/linux-how-to/install-php-7-centos-7-fedora-21/

作者:Aun Raza 译者:wi-cuckoo 校对:wxy

本文由 LCTT 原创翻译,Linux 中国 荣誉推出

来源:http://linux.cn/article-5501-1.html

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-05/117960.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计5789字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中