error Received malformed response from registry for undefined. The registry may be down.

Laravel 学习中

https://laravel-china.org/courses/laravel-essential-training-5.5/569/style-beautification

执行下列代码时报错

$ yarn install --no-bin-links
$ yarn add cross-env

error Received malformed response from registry for undefined. The registry may be down. Continue reading error Received malformed response from registry for undefined. The registry may be down.

解决 WordPress 后台主题中只显示一个主题不显示其他主题的问题

出现 WordPress 主题无法识别问题的原因:服务器环境禁用了 scandir 函数,导致 WordPress 无法正常扫描主题。

解决方法:

  • 找到 php.ini,一般在服务器的 /usr/local/php/etc 目录下;
  • 打开 php.ini,查找其中的 “disable_functions” 字样,找到并删除紧随其后的 “scandir” ,最后保存该文件;
  • 重启服务器的 php 服务。

 

网站 ald 安装的一些记录

Call to undefined function Think\Session\Driver\mysql_connect()

Conf/common.php 的 SESSION_TYPE 留空,如写 db 则以 mysql 为驱动,会报上述错误

nginx 引入文件 include vhost/other/osv2_nginx.conf;

nginx 主要配置项 重写 thinkphp index.php 文件,取消引入 php7 的 pathinfo.php,引入 osv2_nginx.conf 重写文件

删除 .user.ini 文件,可能造成 No input file specified

MySQL 报错 this is incompatible with sql_mode=only_full_group_by [ SQL语句 ] 解决办法

这个错误的原因是高版本 MySQL  默认的 sql_mode 包含 ONLY_FULL_GROUP_BY,这个属性保证了 select 到的列都在 group by 中出现。

修改 MySQL 配置文件,通过手动添加 sql_mode 的方式强制指定不需要 ONLY_FULL_GROUP_BY 属性,my.cnf 位于 etc 文件夹下,vim (vim /etc/my.cnf) 下光标移到最后,添加如下:

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

ThinkPHP 3.2 连接多数据库

<?php

return array(
    /* 数据库设置 */
    'DB_TYPE'               =>  'mysqli',     // 数据库类型
    'DB_HOST'               =>  'localhost', // 服务器地址 rds190co1ii65n556p9v.mysql.rds.aliyuncs.com
    'DB_NAME'               =>  'kh',          // 数据库名
    'DB_USER'               =>  'root',      // 用户名
    'DB_PWD'                =>  'root',          // 密码
    'DB_PORT'               =>  '3306',        // 端口
    'DB_PREFIX'             =>  'bj_',    // 数据库表前缀
    'DB_PARAMS'          	=>  array(), // 数据库连接参数
    'DB_DEBUG'  			=>  TRUE, // 数据库调试模式 开启后可以记录SQL日志
    'DB_FIELDS_CACHE'       =>  true,        // 启用字段缓存
    'DB_CHARSET'            =>  'utf8',      // 数据库编码默认采用utf8
    'DB_DEPLOY_TYPE'        =>  0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
    'DB_RW_SEPARATE'        =>  false,       // 数据库读写是否分离 主从式有效
    'DB_MASTER_NUM'         =>  1, // 读写分离后 主服务器数量
    'DB_SLAVE_NO'           =>  '', // 指定从服务器序号
    'DB_CONFIG2'=>array(
        /* 数据库设置 */
        'DB_TYPE'               =>  'mysqli',     // 数据库类型
        'DB_HOST'               =>  'localhost', // 服务器地址 rds190co1ii65n556p9v.mysql.rds.aliyuncs.com
        'DB_NAME'               =>  'ald',          // 数据库名
        'DB_USER'               =>  'root',      // 用户名
        'DB_PWD'                =>  'root',          // 密码
        'DB_PORT'               =>  '3306',        // 端口
        'DB_PREFIX'             =>  'ocenter_',    // 数据库表前缀
        'DB_PARAMS'          	=>  array(), // 数据库连接参数
        'DB_DEBUG'  			=>  TRUE, // 数据库调试模式 开启后可以记录SQL日志
        'DB_FIELDS_CACHE'       =>  true,        // 启用字段缓存
        'DB_CHARSET'            =>  'utf8',      // 数据库编码默认采用utf8
        'DB_DEPLOY_TYPE'        =>  0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
        'DB_RW_SEPARATE'        =>  false,       // 数据库读写是否分离 主从式有效
        'DB_MASTER_NUM'         =>  1, // 读写分离后 主服务器数量
        'DB_SLAVE_NO'           =>  '', // 指定从服务器序号
    )
);
使用默认的:M('tablename')
使用第二个:M('tablename','表前缀','DB_CONFIG2')

 

使用 PHP 强制下载 PDF 文件

public function test(){

    $this->forceDownload("/Uploads/Attachment/test.pdf");
}


function forceDownload($filename) {

//    if (false == file_exists($filename)) {
//        return false;
//    }

    // http headers
    header('Content-Type: application-x/force-download');
    header('Content-Disposition: attachment; filename="' . basename($filename) .'"');
    header('Content-length: ' . filesize($filename));

    // for IE6
    if (false === strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6')) {
        header('Cache-Control: no-cache, must-revalidate');
    }
    header('Pragma: no-cache');

    // read file content and output
    return readfile($filename);
}