一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

使用源碼編譯安裝PHP7

 php入門(mén) 2015-11-02
php7-install.md  

使用源碼編譯安裝PHP7

2015年6月11日,PHP官網(wǎng)發(fā)布消息,正式公開(kāi)發(fā)布PHP7第一版的alpha版本.

### PHP7特性:

PHP 7.0.0 Alpha 1使用新版的ZendEngine引擎,帶來(lái)了許多新的特性,以下是不完全列表:
(1)性能提升:PHP7比PHP5.6性能提升了兩倍。 Improved performance: PHP 7 is up to twice as fast as PHP 5.6
(2)全面一致的64位支持。 Consistent 64-bit support
(3)以前的許多致命錯(cuò)誤,現(xiàn)在改成拋出異常。Many fatal errors are now Exceptions
(4)移除了一些老的不在支持的SAPI(服務(wù)器端應(yīng)用編程端口)和擴(kuò)展。Removal of old and unsupported SAPIs and extensions
(5)新增了空接合操作符。The null coalescing operator (??)
(6)新增加了結(jié)合比較運(yùn)算符。Combined comparison Operator (<=>)
(7)新增加了函數(shù)的返回類型聲明。Return Type Declarations
(8)新增加了標(biāo)量類型聲明。Scalar Type Declarations
(9)新增加匿名類。Anonymous Classes

### 系統(tǒng)環(huán)境:
```
Mac-mini:~ WangTom$ uname -mnprs
Darwin Mac-mini.local 14.3.0 x86_64 i386

Mac-mini:~ WangTom$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.3
BuildVersion: 14D136
```

### 源碼安裝PHP7:

PHP7下載地址:https://downloads./~ab/

```
$ wget https://downloads./~ab/php-7.0.0alpha1.tar.bz2
$ tar jxf php-7.0.0alpha1.tar.bz2
$ cd php-7.0.0alpha1

$ ./configure
... ...
checking size of long... (cached) 8
checking size of long long... (cached) 8
checking for iconv support... yes
checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=

```

安裝 libiconv (字符編碼轉(zhuǎn)換庫(kù))
網(wǎng)站地址: http://www./software/libiconv/
當(dāng)前版本: http://ftp./pub/gnu/libiconv/libiconv-1.14.tar.gz

```
$ wget http://ftp./pub/gnu/libiconv/libiconv-1.14.tar.gz
$ tar zxf libiconv-1.14.tar.gz
$ cd libiconv-1.14
$ ./configure --prefix=/usr/local/lib/libiconv
$ make
$ sudo make install
```


配置參數(shù)
```
$ ./configure --prefix=/usr/local/php7 \
--enable-fpm \
--with-config-file-path=/usr/local/php7/etc \
--with-iconv=/usr/local/lib/libiconv \

執(zhí)行configure配置后,可以看到有如下結(jié)果:
... ...
Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands  
WangTomdeMacBook-Pro:php-7.0.0alpha1 wangtom$ 
```
$ make
$ make test
$ sudo make install

查看PHP7是否安裝成功
````
WangTomdeMacBook-Pro:php-7.0.0alpha1 wangtom$ /usr/local/php7/bin/php -v
PHP 7.0.0alpha1 (cli) (built: Jun 20 2015 00:04:19) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies

Mac-mini:~ WangTom$ sudo ln -s /usr/local/php7/bin/php /usr/bin/php7

Mac-mini:~ WangTom$ php -v
PHP 5.5.20 (cli) (built: Feb 25 2015 23:30:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Mac-mini:~ WangTom$ php7 -v
PHP 7.0.0alpha1 (cli) (built: Jun 23 2015 17:24:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies

Mac-mini:php-fpm.d WangTom$ which php
/usr/bin/php
Mac-mini:php-fpm.d WangTom$ which php7
/usr/bin/php7
```

### 配置PHP-FPM: 

Nginx不支持對(duì)外部程序的直接調(diào)用或者解析,所有的外部程序(包括PHP)必須通過(guò)FastCGI接口來(lái)調(diào)用。
PHP-FPM是一個(gè)PHP FastCGI管理器,新版的PHP已經(jīng)集成了php-fpm,在./configure的時(shí)候帶 –enable-fpm參數(shù)即可開(kāi)啟PHP-FPM.
FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites.

啟動(dòng) PHP-FPM: 
```
Mac-mini:php7 WangTom$ /usr/local/php7/sbin/php-fpm
[23-Jun-2015 15:33:01] WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' from /usr/local/php7/etc/php-fpm.conf at line 125.
[23-Jun-2015 15:33:01] ERROR: failed to open error_log (/usr/local/php7/var/log/php-fpm.log): Permission denied (13)
[23-Jun-2015 15:33:01] ERROR: failed to post process the configuration
[23-Jun-2015 15:33:01] ERROR: FPM initialization failed
```
提示錯(cuò)誤說(shuō)/usr/local/php7/var/log/php-fpm.log 沒(méi)權(quán)限,就給777權(quán)限:
$ chmod 777 /usr/local/php7/var/log/

修改 php-fpm 配置文件:
$ cd /usr/local/php7/etc/
$ cp php-fpm.conf.default php-fpm.conf
$ vim php-fpm.conf
  > 打開(kāi) error_log這一行的注釋,默認(rèn)該項(xiàng)被注釋掉,若不修改會(huì)出現(xiàn)提示log文件路徑不存在
  > error_log = /usr/local/php7/var/log/php-fpm.log 
  > 打開(kāi)inclue這一行的注釋
  > include=/usr/local/php7/etc/php-fpm.d/*.conf

修改 /usr/local/php7/etc/php-fpm.d/www.conf 文件:
如果這個(gè)文件不存在,就從default復(fù)制一份:
$ cd /usr/local/php7/etc/php-fpm.d/
$ cp www.conf.default www.conf
將配置文件中的 user 和 group 部分的 nobody 改成 www:
$ vim /usr/local/php7/etc/php-fpm.d/www.conf
  > user  = www  
  > group = www  

開(kāi)始啟動(dòng) php-fpm:
```
Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm
[23-Jun-2015 18:30:48] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[23-Jun-2015 18:30:48] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[23-Jun-2015 18:30:48] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[23-Jun-2015 18:30:48] ERROR: FPM initialization failed
```
這個(gè)錯(cuò)誤問(wèn)題有兩個(gè):(1)沒(méi)有使用root賬戶執(zhí)行啟動(dòng)命令 (2)端口9000被占用
解決方法:
使用root賬戶執(zhí)行php-fpm啟動(dòng),或 sudo /usr/local/php7/sbin/php-fpm  
關(guān)閉 PHP-fpm, 并重新啟動(dòng):
```
Mac-mini:~ WangTom$ lsof -P | grep ':9000' | awk '{print $2}' | xargs kill -9
Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm -t
[23-Jun-2015 18:30:25] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful
Mac-mini:~ WangTom$ sudo /usr/local/php7/sbin/php-fpm
Mac-mini:~ WangTom$ 
```

修改Nginx 配置: 
在 nginx.conf 配置文件server 部分增加fastcgi配置,并重新加載配置文件:
```
Mac-mini:~ WangTom$ sudo vim /usr/local/nginx/conf/nginx.conf

> location ~ \.php$ {
>  root html;
>  fastcgi_pass 127.0.0.1:9000;
>  fastcgi_index index.php;
>  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>  include fastcgi_params;
> }

Mac-mini:~ WangTom$ sudo /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Mac-mini:~ WangTom$ sudo /usr/local/nginx/sbin/nginx -s reload
Mac-mini:~ WangTom$
```

用到的一些命令:

uname: 用來(lái)獲取電腦和操作系統(tǒng)的相關(guān)信息
sw_vers: Mac下查看系統(tǒng)版本信息
lsof: 列出當(dāng)前系統(tǒng)打開(kāi)文件(list open files)
which: 指令會(huì)在環(huán)境變量$PATH設(shè)置的目錄里查找符合條件的文件


參考鏈接:

- http:///archive/2015.php#id2015-06-11-3
- http://www./blog/compiling-and-installing-php7-ubuntu


[END]

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    在线观看中文字幕91| 五月婷婷综合缴情六月| 国产欧美日韩综合精品二区| 最新国产欧美精品91| 亚洲中文字幕视频在线观看| 97人妻精品免费一区二区| 国产毛片对白精品看片| 中文字幕高清不卡一区| 中文字幕有码视频熟女| 亚洲中文在线中文字幕91| 日系韩系还是欧美久久 | 亚洲国产黄色精品在线观看| 日韩精品一级一区二区| 日韩亚洲激情在线观看| 日韩精品视频一二三区| 国产精品白丝一区二区| 日韩日韩日韩日韩在线| 国产精品涩涩成人一区二区三区| 久久福利视频视频一区二区| 国产偷拍精品在线视频| av国产熟妇露脸在线观看| 欧美日韩亚洲国产综合网| 日本人妻精品有码字幕| 小草少妇视频免费看视频| 中文字幕久久精品亚洲乱码| av一区二区三区天堂| 免费福利午夜在线观看| 亚洲欧美视频欧美视频| 日韩一区中文免费视频| 免费特黄一级一区二区三区| 国产欧美精品对白性色| 久久女同精品一区二区| 欧美尤物在线观看西比尔| 九九视频通过这里有精品| 永久福利盒子日韩日韩| 熟女乱一区二区三区四区| 好吊一区二区三区在线看| 麻豆亚州无矿码专区视频| 激情五月天深爱丁香婷婷| 午夜国产精品国自产拍av| 大尺度剧情国产在线视频|