Centos安装Nginx

# 依赖 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel # 下载安装包 wget http://nginx.org/download/nginx-1.13.7.tar.gz # 解压 tar -xvf # 进入运行文件 ./configure # 运行编译 make # 安装 make install nginx reload 重启 service nginx restart nginx -t 验证配置文件 # 一份模板,不完整 worker_processes 1; events { worker_connections 1024; } http {...

read more..

Nodejs,Mysql连接出错

const connection = mysql.createConnection(db)长时间不操作mysql,会自动关闭连接,导致服务中断。 修改为:使用连接池const connection = mysql.createPool(db) const mysql = require('mysql'); const config = require('./config') const conn = mysql.createPool(config.db); var queryDB = function(qry, cb) { conn.getConnection(function(error, conne...

read more..

speedtest-cli测试带宽

# wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py # chmod +rx speedtest.py # sudo mv speedtest.py /usr/local/bin/speedtest-cli # sudo chown root:root /usr/local/bin/speedtest-cli speedtest-cli --bytes以字节计算的方式来测试上下行速度 speedtest-cli --share将速度测试的结果生成一张图片的连接,便于你分享 speedtest-cli --simple只显示ping和上下行速...

read more..

使用request后台发送请求

处理有跨域的接口。后台调用 const request = require('request'); router.get("/wnl", (req, res) => { request('https://www.sojson.com/open/api/lunar/json.shtml', function(error, response, body) { if (!error && response.statusCode == 200) { console.log(body) // Show the HTML for the baidu homepage. } else { console.log(resp...

read more..

阿里大鱼发送短信

// 配置 const Core = require('@alicloud/pop-core'); var client = new Core({ accessKeyId: '****', // id accessKeySecret: '***', // 密钥 endpoint: 'https://dysmsapi.aliyuncs.com', apiVersion: '2017-05-25' }); // 用户模板信息 var params = { "RegionId": "cn-hangzhou", "PhoneNumbers": emailNum, //电话号码 "SignName": "***", //名片 ...

read more..

阿里OSS存储

nodejs发送文件到public内,调用oss接口上传文件。 <input type="file" name="" id="photo"> $("#photo").on("change", function () { let file = $(this)[0].files[0]; let formdata = new FormData(); formdata.append("photo", file); $.ajax({ type: 'post', url: '/api/pro/picture', data: formdata, ...

read more..

一段神奇的代码

alert((++[[]][+[]]/[]+[])[+[]]+([{}]+[])[++[[]][+[]]+[+[]]-+!+[]-+!+[]-+!+[]]+(![]+[])[!+[]+!+[]]+([{}]+[])[+!+[]]+'v'+(-{}+[]+[]+[][+[]])[+!+[]+[+[]]]+([{}]+[])[++[[]][+[]]+[+[]]-+!+[]-+!+[]-+!+[]]+(++[[]][+[]]/[]+[])[+!+[]+[+[]]-!+[]-!+[]-!+[]]+([{}]+[])[+!+[]]+([][[]]+[])[+[]]);

read more..

Docker

安装yum update –更新yum install -y yum-utils device-mapper-persistent-data lvm2 –依赖yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo –换源yum list docker-ce –showduplicates | sort -r –查看docker版本yum install docker-ce-17.12.1.ce –选择版本安装 常用命令docker start/stop –启动停止docker i...

read more..

Nodejs流

const fs = require("fs")// 创建写入流,就是先创建个文件。这个文件是空的。 let ws = fs.createWriteStream('./public/upload/' + fileName); 写入数据 这里是二进制数据ws.write(req.file.buffer);  监听打开ws.on("open",function(fd){     console.log("文件正在打开",fd);  })监听关闭ws.end(function(){ &n...

read more..