下載: 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便可.