分类 php 下的文章

网上查是缺少是GD库中缺少freetype库,下面是按照步骤
1、下载freetyp包
官方地址:https://download.savannah.gnu.org/releases/freetype/ 或者 https://sourceforge.net/projects/freetype/files/
执行下载:

  sudo wget https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.bz2 --no-check-certificate

2、解压缩包

   sudo tar xvf freetype-2.10.0.tar.bz2 

3、进入freetype,

   cd freetype-2.10.0

4、执行编译安装

   sudo make clean
   sudo ./configure --prefix=/usr/local/php-7.3.27 --with-config-file-path=/usr/local/php-7.3.27/etc --enable-bcmath --enable-fpm --enable-sockets --enable-ftp --enable-mbstring --enable-opcache --with-gd --with-freetype-dir --with-webp-dir --with-jpeg-dir --with-png-dir --enable-zip --with-zlib-dir --enable-xml --with-bz2 --with-curl --with-gettext --with-mysqli --with-pdo-mysql --with-openssl --with-fpm-user=www --with-fpm-group=www --without-sqlite3 --without-pdo-sqlite --with-pear   (注:这里以自己的实际目录为准)
  make 
  make install
  

5、重启php

   sudo systemctl restart php-fpm

6、phpinfo()查看是否安装成功

示例:

function delDirFile($dir) {
    //先删除目录下的文件:
    $dh=opendir($dir);
    while ($file=readdir($dh)) {
        if($file!="." && $file!="..") {
            $fullpath=$dir."/".$file;
            if(!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                deldir($fullpath);
            }
        }
    }
    closedir($dh);
    //删除当前文件夹:
    if(rmdir($dir)) {
        return true;
    } else {
        return false;
    }
}

//用法
$dir = "/User/xxx/Sites/xxx/";
delDirFile($dir);

下载安装,参考:https://github.com/yosa/predis

引入predis,例如:
require 'vendor/predis/predis/autoload.php'; //以实际路径为准
Predis\Autoloader::register();

使用:

$redis = new Predis\Client(
    [
        'host' => $redisInfo['path'],  //服务器地址
        'port' => $redisInfo['port'],  //端口
        'database' => $redisInfo['select'], //连接数据库
        'password' => $redisInfo['auth'], //密码
    ]
);
$redis->set("test", 11);
var_dump($redis->get("test")); //打印11

背景:
最近用es做数据检索,需要统计满足条件的zwk_zkrs字段的总和,特来记录一下
求和:

$params["body"]["aggs"]["total_zkrs"] = [
   "sum" => [
       "field" => "zwk_zkrs"
   ]
];
求平均值
$params["body"]["aggs"]["avg_zkrs"] = [
   "avg" => [
       "field" => "zwk_zkrs"
   ]
];

注:total_zkrs为自定义内容,sum为求和参数,avg为求平均值,zwk_zkrs为求和字段,
参考文献:
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_aggregation_test_drive.html