本站即日起正式部署SSL证书启用https安全连接, 联系站长:416326801#qq.com(#改成@)

Latest from the blog

curl封装函数

标签: PHP

//curl接口请求方法封装
function curl_get_contents($url,$data = '',$headers=[], $https = false)
{
    $results['error']   = '';
    $results['status']  = 0;
    $results['data']    = array();
    $user_agent         =  $_SERVER['HTTP_USER_AGENT'];
    $curl     = curl_init();// 启动一个CURL会话


    if( !empty($data))
    {
        curl_setopt($curl, CURLOPT_POST, 1);    // 发送一个常规的Post请求
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);    // Post提交的数据包
    }
    if( $https )
    {
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);    // 对认证证书来源的检查
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);// 从证书中检查SSL加密算法是否存在
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);    // 使用自动跳转
    }
    curl_setopt($curl, CURLOPT_URL, $url);  // 要访问的地址
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);// 设置超时限制防止死循环
    curl_setopt($curl, CURLOPT_HEADER, 0);  // 显示返回的Header区域内容
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);    // 获取的信息以文件流的形式返回
    curl_setopt($curl, CURLOPT_USERAGENT,$user_agent);// 模拟用户使用的浏览器
    curl_setopt($curl, CURLOPT_AUTOREFERER, 1);       // 自动设置Referer
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);


    $results['data']        = curl_exec($curl); // 执行操作
    if (curl_errno($curl))
    {
        $results['error']    = curl_error($curl);//捕抓异常
    }
    curl_close($curl);      // 关闭CURL会话
    return $results;        // 返回数据

}

 

CentOS7修改SSH端口提示error: Bind to port

vi /etc/ssh/sshd_config
Port 10000
semanage port -l|grep ssh  
semanage port -a -t ssh_port_t -p tcp 10000
semanage port -l|grep ssh  
/bin/systemctl restart  sshd.service

出现如下提示,可以关闭SELlinux或者执行semanage port -a -t ssh_port_t -p tcp 10000

Jan 23 17:02:10 localhost.localdomain systemd[1]: Starting OpenSSH server dae...
Jan 23 17:02:10 localhost.localdomain sshd[14030]: error: Bind to port 10000 ...
Jan 23 17:02:10 localhost.localdomain sshd[14030]: error: Bind to port 10000 ...
Jan 23 17:02:10 localhost.localdomain sshd[14030]: Server listening on 0.0.0....
Jan 23 17:02:10 localhost.localdomain sshd[14030]: Server listening on :: por...
Jan 23 17:02:10 localhost.localdomain systemd[1]: Started OpenSSH server daemon.


Linux安装Docker

标签: Linux yum

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
service docker start
vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://*****.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker
yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
total 44
-rw-r--r--. 1 root root 2573 Mar 21  2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 Nov 30  2016 CentOS-Base.repo.backup
Docker加速
[root@localhost ~]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://*****.mirror.aliyuncs.com"]
}

Linux升级内核kernel

标签: Linux yum kernel

uname -r
yum groupinstall "Development Tools" -y
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --disablerepo="*" --enablerepo="elrepo-kernel"list available
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
yum --enablerepo=elrepo-kernel install kernel-lt
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg 
grub2-set-default0
reboot
uname -r

启动项

[root@localhost ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.4.112-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-514.10.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-5bb255f67f7f40dd8f4af646ea15c6b5) 7 (Core)
1 2 3 4 5 6 7 8 9 10 ... Next »... Last »