改變|PHP7在開發機上的安裝使用之旅

下載7:php

$ cd
$ mkdir php7test
$ cd php7test
$ wget http://cn2.php.net/get/php-7.0.7.tar.gz/from/this/mirror
$ tar -zxvf php-7.0.7.tar.gz
$ cd php-7.0.7

安裝一些依賴:html

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

配置configuremysql

$ ./configure --prefix=/data/php7 --with-config-file-path=/data/php7/etc --with-config-file-scan-dir=/data/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=xxxxxxxxxx --with-fpm-group=xxxxxxxxxx --with-gd --with-iconv --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --with-zlib --enable-bcmath --enable-sockets

而後:nginx

$ make
$ make install

默認安裝好以後,你會發現/data/php7/etc下面沒有php.ini文件,這個去哪裏要呢?在php7的源碼安裝包都有。sql

進入源碼安裝包的目錄segmentfault

$ cd 
$ cd php7test/php-7.0.7
$ ls

能夠看到有兩個php.ini-xxx的文件api

$ cp php.ini* /data/php7/etc/
$ cp php.ini-production /data/php7/etc/php.ini

啓用php-fpm

先配置config文件session

$ cd /data/php7/etc
$ cp php-fpm.conf.default php-fpm.conf
$ cp php-fpm.d/www.conf.default php-fpm.d/www.conf

在編譯以前./configure的時候,咱們都已經肯定了一些配置,好比運行fpm的用戶和用戶組之類的,因此默認配置應該不會存在路徑問題和權限問題。php7

搞定php-fpm的服務載入curl

咱們但願使用service php-fpm start|stop|restart這些操做來實現服務的重啓,但沒有像nginx那麼複雜,php編譯好以後,給咱們提供了一個php-fpm的程序,不須要我再編寫分享了。這個文件放在php編譯源碼目錄中:

$ cd 
$ cd php7test/php-7.0.7/sapi/fpm
$ cp init.d.php-fpm /etc/init.d/php-fpm
$ chmod +x /etc/init.d/php-fpm
$ chkconfig --add php-fpm
$ chkconfig php-fpm on

經過上面這個操做,咱們就能夠使用sevice php-fpm start來啓用php-fpm了。用ps -ef | grep php-fpm看看進程吧。

或者經過使用/data/php7/sbin/php-fpm來啓動php7.

Finish & Success

參考

  1. http://blog.thinkerphp.com/Index/detail/id/125.html

  2. http://www.javashuo.com/article/p-bbuvgrba-cs.html

相關文章
相關標籤/搜索