持续创作,加速成长!这是我参与「掘金日新计划 · 6 月更文挑战」的第13天,点击查看活动详情
配置 nginx 静态文件服务器
配置nginx作为静态文件夹服务器,需要注意的是window下的路径需要设置为 \\。
比如:D:\\temp\\static
server {
listen 8081;
server_name localhost;
location /niu {
alias D:\\niuStatic;
autoindex on; #显示索引
autoindex_exact_size on; #显示大小
autoindex_localtime on; #显示时间
}
}
注意在window下启动nginx前先杀一下进程:taskkill /f /im nginx.exe
结果如图:
在不使用编程语言的情况下,在 JSON 对象里返回客户端的 IP 地址
location /ip {
default_type text/plain;
return 200 $remote_addr;
}
访问 localhost:8081/ip 如图:
甚至可以返回JSON格式化后的数据
location /json_ip {
default_type application/json;
return 200 "{\"ip\":\"$remote_addr\"}";
}
访问 localhost:8081/json_ip 如图:
删除arr1中的arr2的元素项
arr1 与 arr2 有部分元素相同,去掉 arr1 中与 arr2 相同的元素
formateArray(arr1, arr2) {
// arr2在arr1中各个元素的索引,保存到indexs中
let indexs = [];
arr2.forEach((item, index) => {
indexs.push(arr1.indexOf(item));
});
//排序
indexs.sort(function(a, b) {
return b - a;
});
//删除
indexs.forEach(function(index) {
arr1.splice(index, 1);
});
return arr1;
},
查看Windows端口占用
比如说需要查看 8081 端口被哪个进程谁占用了
netstat -aon|findstr "8081"
查看结果
端口被进程号为 13224 的进程占用,继续执行下面命令:
tasklist|findstr "13224"
结果如图:
nginx占用了你的端口,有三种杀掉进程的方法。
- 强制终止进程
taskkill /F /pid 1408
- 从软件入手,首先进入到这个软件的可执行文件目录处,也就是exe文件处
taskkill /f /im nginx.exe
- 任务管理器法
进程—查看—选择列—pid(进程位标识符)打个勾找到该进程号对应的任务,结束任务。