一、安裝Yaf
Yaf其實算是PHP官方的一個擴展,我們可以直接在PHP官網(wǎng)下載。
官網(wǎng)地址:http://pecl.php.net/package/yaf
github :https://github.com/laruence/php-yaf
下載完成后解壓,在解壓目錄下面只需要依次執(zhí)行以下幾個步驟 :
1.phpize
2../configure --with-php-config=/data/php/bin/phpize/php-config
3.make & make install
4.修改php.ini 配置文件,添加 extension=yaf.so
二、yaf的目錄結構?

三、在nginx上配置yaf,以下是我的配置。
server {
? ? listen? ? ? 80;#監(jiān)聽的端口號,這個由你自己來定
? ? server_name? yaf.com;#這個是我主機的ip,隱藏了后兩個
? ? index index.html index.htm index.php;
? ? root? /www/YafWeb/;
? ?location ~ .*\.(php|php5)?$
? ? {
? ? ? ? #fastcgi_pass? unix:/tmp/php-cgi.sock;
? ? ? ? fastcgi_pass? 127.0.0.1:9000;
? ? ? ?fastcgi_index index.php;includefastcgi.conf;
? ? }
? ? location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
? ? {
? ? ? ? expires 30d;
? ? }
? ? location ~ .*\.(js|css)?$
? ? {?
? ? ? ? expires 1h;
? ? }
? ? #偽靜態(tài)規(guī)則
? ? location /{
? ? ? ? if(!-e$request_filename) {
? ? ? ? ? ? rewrite ^/(.*)/index.php?$1 last;
? ? ? ? }
? ? }
? ? access_log? /alidata/log/nginx/access/yafweb.log;
}
重啟nginx
/etc/init.d/nginx reload
#或者
/etc/init.d/nginx restart