centos 7 安裝php7 轉載

  1. 首先從php官網下載php7的源碼包:php

    下載地址:mysql

    http://php.net/downloads.phpnginx

    我下載的版本是:php-7.2.4.tar.gzweb

  2. 而後在./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

  3. 下面是三步走:

    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的基本原理,後面的博文會陸續深刻講解,本篇主要以安裝爲主,就先講解到此.

相關文章
相關標籤/搜索