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

编译自:http://linoxide.com/linux-how-to/install-php-7-centos-7-fedora-21/作者: Aun Raza
原创:LCTT https://linux.cn/article-5501-1.html译者: wi-cuckoo
转载地址:https://linux.cn/article-5501-1.html

PHP7

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

在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. [[email protected] php7]# git clone https://git.php.net/repository/php-src.git
  2. Cloning into ‘php-src‘...
  3. remote: Counting objects: 615064, done.
  4. remote: Compressing objects: 100% (127800/127800), done.
  5. remote: Total 615064 (delta 492063), reused 608718 (delta 485944)
  6. Receiving objects: 100% (615064/615064), 152.32 MiB | 16.97 MiB/s, done.
  7. Resolving deltas: 100% (492063/492063), done.

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

  1. cd php-src
  2. ./buildconf

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

  1. [[email protected] 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 in this |
  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 do not agree with the terms of this license, you must abort |
  13. | the installation process at this point. |
  14. +--------------------------------------------------------------------+
  15. Thank you for using 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. [[email protected] 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. [[email protected] cli]# ./php -v
  2. PHP 7.0.0-dev (cli) (built: Mar 28 2015 00:54:11)
  3. Copyright (c) 1997-2015 The PHP Group
  4. Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies

总结

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

时间: 2024-08-11 19:28:45

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0的相关文章

如何在Windows 8下创建Fedora 21 Live USB

Fedora 21的Beta版本已经提供下载,Fedora 21 Beta也带来了一些新的特性,那么如何创建一个Fedora 21 Live USB呢?方法有很多种,今天只介绍一种. 需要的工具 装有Windows 7或者Windows 8的电脑 4GB的U盘 Rawrite32软件(下载) Fedora 21镜像(下载) 创建Fedora 21 Live USB 1.打开Rawrite32 默认情况下打开窗口并不会显示ISO文件,所以你需要点击右下角的所有文件,来显示目录下的所有文件.同时你要

vmware 11下fedora 21 共享的问题

vmware 11下f安装fedora21,建立共享注意: 使用的fedora 内核为:3.17.4-301.fc21.x86_64 可以使用命令查看: [[email protected] share fedora 21]# uname -r3.17.4-301.fc21.x86_64 按照正常的安装共享目录的方法去做,在虚拟机上选择:虚拟机---安装vmware tools, 接下来我是这么做的,创建一个目录/root/tools,将vmware tools中的文件复制到该目录下, 然后解压

Fedora 21 安装 Budgie Desktop

Budgie Desktop 是一款自由开源桌面,是 Evolve OS 的默认桌面,Evolve OS 是一款 OpenSUSE 的衍生系统.Budgie Desktop 属于一款轻量级的桌面系统,一款很好的旧电脑和使用ARM体系结构电脑的桌面替代品.同时还支持Wayland. 可用的最新版本Budgie Desktop 2.0最近已发布.其中面板已变得透明,菜单搜索栏已经被移动的顶部,一些小程序得到增强,系统的关机和重启已改进支持和一些错误修复. 安装 Fedora 21 系统上的安装命令:

Fedora 21 64位系统安装WPS教程

WPS的Linux版本的出现简直是Linux党的福音,Ubuntu上的WPS安装非常简单,但是在Fedora上却有点小麻烦.主要是库的依赖问题.下面记录一下Fedora 21的64位版安装WPS的完整过程以备忘. 1.WPS官网下载最新的WPS for Linux版: http://community.wps.cn/download/ (64位下载i686的rpm包) 2.终端使用rpm命令安装(习惯于将常用软件安装在系统中,所以都用sudo): sudo rpm -ivh wps-office

fedora 21下Virtual Box安装Windows XP SP3

Installing Virtual Box and Windows XP SP3 during Fedora 21 The first step:Download and Install Virtual BoxThe first method:Download address:https://www.virtualbox.org/wiki/Downloads;According to system, we click onVirtualBox 4.3.20 for Linux hosts, a

Fedora 21 install chrome

Steps to install Google Chrome on Fedora 21 A. Create google-chrome.repo file Use this command to create google-chrome.repo file under /etc/yum.repos.d su yum install nano nano /etc/yum.repos.d/google-chrome.repo Then add the following lines to the n

[转载]Install Opera 12.16 Web Browser in CentOS/RHEL and Fedora

FROM: http://tecadmin.net/install-opera-web-browser-in-centos-rhel-fedora/ Opera is an modern web browser with modern style with powerful features. Its Off-Road mode compresses pages for faster, all-conditions browsing. It helps you stay online when

fedora 21 解决rtl8192ee 网卡wifi连接不稳定问题

自从把 系统fedora19升级到fedora 20 fedora 21之后我笔记本本身自带的无线网卡就算是报废了,一直到最近才看到相关资料解决了问题: 在这里把我的解决方法留个记录,给大家做个参考: 一般来说fedora 21 的无线网卡驱动,只要yum update就可以正常使用了,但是有些网卡是不被很好的支持的,比如最新的网卡,而万恶的网卡商在linux下的驱动开发动力小,造成类似我这样喜欢玩的人很大困扰: 接下来进入正题,首先如果你的wifi不能正常使用,那就先插上网线或者用其他上网方式

U盘安装Fedora 21

1.使用powerISO刻录fedora 21 为可启动U盘 2.修改引导项为从U盘启动 3.出现安装选项的时候按下e进行编辑 4.修改root...LABEL=/dev/sdb4,其中/dev/sdb4为U盘路径 5.按下esc退出编辑,选择其中一个安装即可