博客

  • Centos7 nginx php 启动关闭命令

    php-fpm 启动、停止、重启

    启动
    systemctl start php-fpm
    停止
    systemctl stop php-fpm
    重启
    systemctl restart php-fpm
    

    Nginx命令

    #启动nginx服务
    systemctl start nginx.service
    #停止nginx服务
    systemctl stop nginx.service
    #重启nginx服务
    systemctl restart nginx.service
    #重新读取nginx配置
    systemctl reload nginx.service
    也可以这样
    nginx -s stop    #停止服务 
    nginx -s quit    #退出服务 
    nginx -s reopen    #重新打开日志文件 
    nginx -s reload    #重新加载配置文件
    
  • Centos7 后台运行脚本

    后台执行关闭SSH不收影响

    后台执行 nohup ./zhuan.sh &
    

    查看后台运行脚本

     $ ps -ef | grep zhuan
    

    关闭后台脚本 杀掉进程

    kill -9 进程ID
    
  • ffmpeg aac_he 提高音质转码命令

    ffmpeg -i "DjSam-打造月半小夜曲包房气氛国粤语串烧(DJ版).mp3" -threads 2 -c:a libfdk_aac -profile:a aac_he -b:a 32k -y "DjSam-打造月半小夜曲包房气氛国粤语串烧(DJ版).m4a"
    

    文件名有空格需要加””号

  • yii2表单验证方法

    return
    [
    [['username','password','email','phone','images'],'required','message'=>'不能为空'],
    //验证唯一性
    [['username'], 'unique','targetClass' => '\backend\models\Verification','message'=>'用户名不能一致'],
    //验证长度
    ['username', 'string', 'min' => 2, 'max' => 8,"tooLong"=>"太长了", "tooShort"=>"太短了"],
    //正则验证
    ['username','match','pattern'=>'/^[a-z]{1,}$/','message'=>'用户名必须为字母'],
    ['password','match','pattern'=>'/^[0-9]{6,12}$/','message'=>'密码必须是数字,且大于6为小于12位'],
    ['email', 'unique', 'targetClass' => '\backend\models\Verification', 'message' => '邮箱名已存在.'],
    //邮箱验证
    ['email','match','pattern'=>'/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/','message'=>'邮箱格式不正确'],
    //手机号验证
    ['phone','match','pattern'=>'/^1[0-9]{10}$/','message'=>'手机号格式不正确'],
     ];
    
  • YII2默认控制器

    /**
    配置文件/config/web.php 
    写到$config = 
    [
    'defaultRoute'=>'link-list/index',
    ]
    **/
    'defaultRoute'=>'link-list/index',
    
  • YII2 联合查询

    //方法get+models使用方法 LinkClass.name
    public function getLinkClass()
     {
      return $this->hasOne(LinkClass::className(), ['id' => 'flid']);
     }
    
  • PHP 模拟post进行url请求 并输出返回内容

         /**
         * 模拟post进行url请求
         * @param string $url
         * @param string $param
         */
        function request_post($url = '', $param = '') {
            if (empty($url) || empty($param)) {
                return false;
            }
            
            $postUrl = $url;
            $curlPost = $param;
            $ch = curl_init();//初始化curl
            curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
            curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
            curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
            curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
            $data = curl_exec($ch);//运行curl
            curl_close($ch);
            
            return $data;
        }