安装YAF扩展

基于阿里云的轻应用服务器安装,(Apache+php-fpm,php5.6)

yum -y install  autoconf
wget http://pecl.php.net/get/yaf-2.3.3
mv yaf-2.3.3 yaf.tar.gz
tar -xzvf yaf.tar.gz
cd yaf-2.3.3
/usr/local/php56/bin/phpize
./configure --with-php-config=/usr/local/php56/bin/php-config
make && make install

安装位置

/usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/

php.ini中配置yaf

编辑文件

/usr/local/php56/etc/php.ini

在文件末尾增加记录

[yaf]
yaf.use_namespace = 1
yaf.environ = 'product'
yaf.cache_config = 0
yaf.name_suffix = 1
yaf.lowcase_path = 1
extension = /usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/yaf.so

修改apache的重写规则

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [QSA,PT,L]

报错:

这是因为用了高版本的yaf导致的。用yaf-2.3.3 就好了。

/root/yaf-3.3.3/php_yaf.h:148:1: error: unknown type name ‘zend_string’

apache重写规则

在网站目录上传文件.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* index.php
</IfModule>