LOADING

分类 PHP 下的文章

今天研究了下https环境配置 比我想象的简单许多 步骤如下
1首先去阿里云搜索ssl ca证书 一个账号可以免费申请20个 一个绑定一个域名 期限为1年
2然后按照点击验证 等候Symantec验证
3验证通过后点击下载QQ截图20191023002606.png

4下载后解压缩文件会得到pem和key 这两个需要放到你服务器上
QQ截图20191023002755.png

5接下来你需要如下配置nginx

server {
        listen 443 ssl default;
        server_name www.baidu.com;
        root /mnt/www/baidu/public;#你的项目入口
        ssl on;
        ssl_certificate /etc/ssl/www.baidu.pem;
        ssl_certificate_key /etc/ssl/www.baidu.key;

        keepalive_timeout   70;
   
        server_tokens off;
        fastcgi_param   HTTPS               on;
        fastcgi_param   HTTP_SCHEME         https;

        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    
        access_log  /var/log/nginx/baidu.log access;
        error_log  /var/log/nginx/err_baidu.log error;
        index index.php index.html;
        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }
        location /app {
            add_header 'Access-Control-Allow-Origin' '*' 'always';
            alias /mnt/www/static_app/public/app-dev;
            try_files $uri $uri/ /index.php?$query_string;
        }

        location /pages/audition/ {
            add_header 'Access-Control-Allow-Origin' '*' 'always';
            try_files $uri $uri/ /pages/audition/;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出>现404
            index  index.html index.htm;
        }

        location /pages/pages/ {
            add_header 'Access-Control-Allow-Origin' '*' 'always';
            try_files $uri $uri/ /pages/pages/;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
            index  index.html index.htm;
        }

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php-fpm;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
}

server {
        listen       80;
        server_name www.baidu.com;
        rewrite ^(.*) https://$host$1 permanent;
}

最后是监听80端口把http请求重写到https

brew tap tigerstrikemedia/homebrew-phalconphp
brew install php72-phalcon    (按照自己需要的版本 php7就是 php70-phalcon)
vim /Applications/MAMP/bin/php/php7.2.20/conf/php.ini
添加扩展
extension=/usr/local/Cellar/php72-phalcon/3.4.2/phalcon.so
重启MAMP
在phpinfo中发现phalcon 就说明安装成功

接下来安装phalcon 官方命令行工具
进入htdocs git clone https://github.com/phalcon/phalcon-devtools.git
获得phalcon-devtools文件夹
cd phalcon-devtools 复制phalcon 为phalcon.php
设置环境变量
ln -s /Applications/MAMP/htdocs/phalcon-devtools/phalcon.php /usr/local/bin/phalcon
设置权限

chmod +x /usr/local/bin/phalcon
重启终端
phalcon commands 查看是否安装成功

接下来是大坑 如果你用的是集成环境 并且没有把mac自带的php环境变量指向mamp中的时候就会报
ERROR: Phalcon extension isn't installed, follow these instructions to install it:
执行
brew link php@7.2
echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile
需要把如上两行写入 ~/.bash_profile文件 (如果没有就新建)
修改后执行source ~/.bash_profile  (如果不可以就先切换到~ 然后执行source bash_profile)
执行 php -v 和 which php检测是否成功
phalcon project demo --enable-webtools

public function collectionPage($datas,$filters){
        $datas_count = $datas->count();
        switch ($filters['sort_by']){
            case "DESC":
                $datas = $datas->sortByDesc($filters['sort'])->forPage($filters['page'],$filters['limit']);
                break;
            case "ASC":
                $datas = $datas->sortBy($filters['sort'])->forPage($filters['page'],$filters['limit']);
                break;
            default:
                $datas = $datas->sortBy($filters['sort'])->forPage($filters['page'],$filters['limit']);
                break;
        }
        $datas = $datas->values()->all();
        $option = [
            "path" => URL::full(),
            "pageName" => "page",
        ];
        return new LengthAwarePaginator($datas,$datas_count,$filters['limit'],$filters['page'],$option);
    }

    /**
     * 递归树形结构分类函数
     * $data 数组记录
     * $pid 父id
     * $level 级别
     * $pre 前置html(可以是空格)
     */
    function getArrArea($data,$pid=0,$level=1,$left=" ┗━") {
        $catArr = array();
        foreach($data as  $cat) {
            if ($cat['pid']==$pid) {
                $cat['level'] = $level;
                if($level>1)
                    $cat['name'] = $left.$cat['name'];
                $catArr[] = $cat;
                $catArr = array_merge($catArr,$this->getArrArea($data,$cat['new_category_id'],$level+1," ".$left));
            }
        }
        return $catArr;
    }

git强制覆盖:

git fetch --all
git reset --hard origin/master
git pull

git强制覆盖本地命令(单条执行):

git fetch --all && git reset --hard origin/master && git pull

首先需要修改php-fpm配置文件
vim /etc/php-fpm.d/www.conf 一般修改vim /etc/php-fpm.conf即可
去掉request_slowlog_timeout 、slowlog的前缀分号';'
设置request_slowlog_timeout =2;

设置完毕
之后需要重启php-fpm
ps aux | grep php-fpm
获取到主进程号
菜皮.png

kill -USR2 第一个进程号 master 就可以了
然后去/var/log/php-fpm/www-slow.log (或者你自己设置的地方进行查看)