一、安装Yaf
Yaf其实算是PHP官方的一个扩展,我们可以直接在PHP官网下载。
官网地址:http://pecl.php.net/package/yaf
下载完成后解压,在解压目录下面只需要依次执行以下几个步骤 :
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;#监听的端口号,这个由你自己来定
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;
}
#伪静态规则
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