美文网首页
Ubuntu20.04 安装Yaf 3.2.3

Ubuntu20.04 安装Yaf 3.2.3

作者: 雨醉风尘 | 来源:发表于2020-05-25 13:32 被阅读0次

    环境情况

    Ubuntu 20.04

    PHP7.3.5

    Nginx/1.18.0


    1:安装Yaf 扩展
    • 下载 yaf 扩展源码

      wget http://pecl.php.net/get/yaf-3.2.3.tgz

    • 解压

      tar -zxvf yaf-3.2.3.tgz

    • 进入到 解压后的目录 yaf-3.2.3 并执行配置命令

      cd yaf-3.2.3

      ./configure --with-php-config=/home/dd/lnmp/php/bin/php-config

    • 编译 && 安装

      make

      make install

    • php.ini 文件配置, 新增如下yaf扩展配置

       // extension_dir 可以通过phpinfo()  中获取
       extension_dir = "/home/dd/lnmp/php/lib/php/extensions/no-debug-non-zts-20180731/"
       extension=yaf.so
    
    • 重启 php-fpm, 再次查看 phpinfo() 信息
    11.png
    2:生成Yaf 基础框架代码

    cd yaf-master/tools/cg

    • 执行命令

    php yaf_cg -a yaf-awesome -d /home/dd/lnmp/www/yaf-awesome

    root@path# php yaf_cg  -a yaf-awesome -d /home/dd/lnmp/www/yaf-awesome
    Outputing Yaf Skeleton to /home/dd/lnmp/www/yaf-awesome
    Generating done
    
    • 查看生成的框架代码
    12.png
    • 配置 Nginx
     server {
            listen       8081;                 # 监听端口
            server_name  localhost;          # 站点域名
            root         /home/dd/lnmp/www/yaf-awesome;               # 站点根目录
            index index.html index.htm index.php;  # 默认导航页
         
            location / {
                index index.html index.htm index.php;
                if (-f $request_filename/index.html){
                    rewrite (.*) $1/index.html break;
                }
                if (-f $request_filename/index.php){
                    rewrite (.*) $1/index.php;
                }
                if (!-f $request_filename){
                    rewrite (.*) /index.php;
                }
             
            }
            # PHP配置
            location ~ \.php$ {
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include       fastcgi_params;
                access_log    /home/dd/lnmp/logs/nginx/access.8080.log;
                error_log     /home/dd/lnmp/logs/nginx/error.8080.log;
            }
        }
    
    • 访问 http://localhost:8081/index.php
    13.png

    安装过程中报错及解决方案

    1:php编译扩展库时报错:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.

    apt-get install m4

    apt-get -y install autoconf

    相关文章

      网友评论

          本文标题:Ubuntu20.04 安装Yaf 3.2.3

          本文链接:https://www.haomeiwen.com/subject/trlyahtx.html