首先从php官网下载php7的源码包:php
下载地址:mysql
http://php.net/downloads.phpnginx
我下载的版本是:php-7.2.4.tar.gzweb
而后在./configure以前,咱们可能对准备要安装的这个版本不太了解,尤为是它应该包含哪些编译参数,这个时候,咱们能够进入到源码目录,如我解压后的源码目录是:sql
/usr/local/src/php/php-7.2.4json
而后运行./configure --help 查看当前版本的编译参数,对于需提早安装的库,最好用yum一次性安装,好比:api
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel服务器
这里我只是部分列举了一下,若是您在安装的时不肯定须要with哪些库或参数,则首先能够想一想本身对版本有没有特殊的需求,其次能够查看./configure --help来更进一步了解;session
通常而言,大部分经常使用库仍是必需要安装的,好比curl,xml,openssl,pear等等;若是以为相关库安装的差很少了,则能够先configure试一下,而后根据报错一一补充并安装,这里就再也不赘述了,若有问题,您能够给我留言。php7
下面是三步走:
./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'
而后 make
而后 make install
特别说明,如php7版本已经移除了mysql扩展,可使用mysqli 或 pdo_mysql 的方式,其余的扩展有不明白的地方,直接看./configure --help 便可;
安装完毕后,看到在相应目录下以及生成了安装之后的相关文件:
[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
关于php sapi 如何和web服务器配合通讯以及mod-php 和 php-fpm的基本原理,后面的博文会陆续深刻讲解,本篇主要以安装为主,就先讲解到此.