本文开发坏境:
- CentOS 7
- PHP 7.0.16
安装PECL
7
$ wget http://pear.PHP.net/go-pear.phar
$ PHP go-pear.phar
//PHP版本 < 7
$ yum install PHP-pear
//否则会报错PHP Parse error: Syntax error,unexpected //'new' (T_NEW) in /usr/share/pear/PEAR/Frontend.PHP on //line 91
安装swoole
PHP on line 249
vi `which pecl`
//找到最后一行
exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.PHP "$@"
去掉 -n 标示
//报错如下
//running: PHPize
//Can't find PHP headers in /usr/include/PHP
//安装 PHP-devel
sudo yum install PHP70w-devel
成功!
//Build process completed successfully
//Installing '/usr/lib64/PHP/modules/swoole.so'
//install ok: channel://pecl.PHP.net/swoole-1.9.8
配置 PHP.ini
安装 Yar和Yaf
= 5.2.0,version <= 5.6.99),installed version is 7.0.16
//注意PHP7,要使用yar-2.0.2
$ sudo ./pecl install yar-2.0.2 //注意yar-2.0.2版本
//添加,json.so 要放到前面。否则会报
//PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/PHP/modules/yar.so' - /usr/lib64/PHP/modules/yar.so: undefined symbol: PHP_json_decode_ex in Unknown on line 0
extension=json.so //放前面
extension=msgpack.so
extension=yar.so
//重启PHP服务
sudo systemctl restart PHP-fpm.service
//其他报错
//perl: warning: Setting locale Failed.
//perl: warning: Please check that your locale //settings:
// LANGUAGE = (unset),// LC_ALL = (unset),// LANG = "en_US.UTF-8"
$ localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
//其他报错
//checking for cURL in default path... not found
//configure: error: Please reinstall the libcurl distribution - easy.h should be in
$ sudo yum -y install curl-devel
//安装Yaf
$ sudo ./pecl install yaf
//更新PHP.ini
extension=yaf.so
//重启服务
$ sudo systemctl restart PHP-fpm.service
//安装脚手架
$ git clone http://pecl.PHP.net/package/yaf
$ cd PHP-yaf/tools/cg
$ PHP yaf-cg app
//配置 项目目录指向 app/index.PHP
//访问配置host
Nginx 配置
PHP index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*) /index.PHP/$1 last;
}
}
Enjoy it!
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对编程之家的支持。
原文链接:https://www.f2er.com/php/17359.html