下载: http://pecl.php.net/package/yaf
php
肯定系统已经安装了gcc、gcc-c++、make、automake、autoconf等依赖库html
sudo apt-get install gcc gcc-c++ make automake autoconf
步骤c++
1.去Pecl下载 Yaf的发布包 [2.2.9],而且解压,并进去 yaf-2.2.9 源码目录git
tar -zxvf yaf-2.1.18.tgz cd yaf-2.1.18 //wget http://pecl.php.net/get/yaf-2.2.9.tgz && tar zxvf yaf-2.2.9.tgz && cd yaf-2.2.9
2.接着依次执行:github
/usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
3.执行完你看到了这么一句,说明你第一步Yaf编译部分是ok了.shell
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
4.查看确认编译后的文件安全
ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ yaf.so //能够看到 yaf.so php扩展也已经帮咱们编译好了
5.配置 php.iniapp
vi /usr/local/php/etc/php.ini [yaf] yaf.environ = product yaf.library = NULL yaf.cache_config = 0 yaf.name_suffix = 1 yaf.name_separator = "" yaf.forward_limit = 5 yaf.use_namespace = 0 yaf.use_spl_autoload = 0 extension=yaf.so //关键步骤:载入yaf.so ,上面也可忽略
6.重启PHPsocket
/etc/init.d/php-fpm restart
7.查看phpinfo()php-fpm
8.问题解决
在升级PHP版本(v5.4.x)后从新安装Yaf,而后配置php.ini载入yaf.so后重启php遇到报错
NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/yaf.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/yaf.so: undefined symbol: output_globals in Unknown on line 0
从报错中看到是由于 extension
的位置的问题, 因而从新编译 Yaf 的时候加上 --with-libdir
/usr/local/php/bin/phpize && ./configure --with-libdir=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525 --with-php-config=/usr/local/php/bin/php-config && make && make install
参考
http://www.youcan.cc/index.php/archives/693
http://www.feiyan.info/20.html
http://www.widuu.com/archives/07/713.html
http://blog.csdn.net/eflyq/article/details/10597201
yaf_code_generator
生成代码1.下载yaf工具包
https://github.com/laruence/php-yaf
2.上传文件到相应目录
/home/software/php-yaf-master
3.进入tools/cg/并执行
cd /home/software/php-yaf-master/tools/cg /usr/local/php/bin/php yaf_cg app #app是生成的目录名
执行以上代码,将在cg/output/目录生成一份yaf的骨架代码
4.复制至项目目录
cp -a /home/software/php-yaf-master/tools/cg/output/app/* /home/wwwroot/project/
遇到的问题
在执行yaf_cg命令时可能报错shell_exec() has been disabled for security reasons
警告: shell_exec()已经出于安全缘由关闭
出现这现象的缘由php配置文件php.ini默认关闭了shell_exec;
解决办法:
vi /usr/local/php/etc/php.ini #编辑 /shell_exec #查找 disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket
去掉disable_functions中的shell_exec和scandir便可.