centos 7 安装php7 转载

  1. 首先从php官网下载php7的源码包:

    下载地址:

    http://php.net/downloads.php

    我下载的版本是:php-7.2.4.tar.gz

  2. 然后在./configure之前,我们可能对准备要安装的这个版本不太了解,尤其是它应该包含哪些编译参数,这个时候,我们可以进入到源码目录,如我解压后的源码目录是:

    /usr/local/src/php/php-7.2.4

    然后运行./configure  --help 查看当前版本的编译参数,对于需提前安装的库,最好用yum一次性安装,比如:

    yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

    这里我只是部分列举了一下,如果您在安装的时不确定需要with哪些库或参数,则首先可以想想自己对版本有没有特殊的需求,其次可以查看./configure  --help来更进一步了解;

    一般而言,大部分常用库还是必须要安装的,比如curl,xml,openssl,pear等等;如果觉得相关库安装的差不多了,则可以先configure试一下,然后根据报错一一补充并安装,这里就不再赘述了,如有问题,您可以给我留言。

  3. 下面是三步走:

    扫描二维码关注公众号,回复: 1087543 查看本文章
    1. ./configure 我准备把它安装在/opt/server/php/ 下面,所以我的./configure 命令是:

      './configure'     '--prefix=/opt/server/php/' '--with-config-file-path=/etc' '--enable-fpm' '--with-fpm-user=nginx' '--with-fpm-group=nginx' '--enable-inline-optimization' '--disable-debug' '--disable-rpath' '--enable-shared' '--enable-soap' '--with-xmlrpc' '--with-openssl' '--with-pcre-regex' '--with-sqlite3' '--with-zlib' '--enable-bcmath' '--with-iconv' '--with-bz2' '--enable-calendar' '--with-curl' '--with-cdb' '--enable-dom' '--enable-exif' '--enable-fileinfo' '--enable-filter' '--with-pcre-dir' '--enable-ftp' '--with-gd' '--with-openssl-dir' '--with-jpeg-dir' '--with-png-dir' '--with-freetype-dir' '--enable-gd-jis-conv' '--with-gettext' '--with-gmp' '--with-mhash' '--enable-json' '--enable-mbstring' '--enable-mbregex' '--enable-mbregex-backtrack' '--with-libmbfl' '--with-onig' '--enable-pdo' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-zlib-dir' '--with-pdo-sqlite' '--with-readline' '--enable-session' '--enable-shmop' '--enable-simplexml' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--with-libxml-dir' '--with-xsl' '--enable-zip' '--enable-mysqlnd-compression-support' '--with-pear' '--enable-opcache'

    2. 然后 make

    3. 然后 make install 

      特别说明,如php7版本已经移除了mysql扩展,可以使用mysqli 或 pdo_mysql 的方式,其他的扩展有不明白的地方,直接看./configure   --help 即可;

    4. 安装完毕后,看到在相应目录下以及生成了安装以后的相关文件:

      [root@jordy php]# pwd

      /opt/server/php

      [root@jordy php]# ls

      bin  etc  include  lib  php  sbin  var

      安装完毕后,启动php-fpm进程:

      /opt/server/php/sbin/php-fpm 

  4. 关于php sapi 如何和web服务器配合通信以及mod-php 和 php-fpm的基本原理,后面的博文会陆续深入讲解,本篇主要以安装为主,就先讲解到此.

 
 
 

猜你喜欢

转载自www.cnblogs.com/chenjingxuan/p/9104219.html