简单的API服务器搭建
2015-12-02 10:20
183 查看
首先需要下载一个Nginx 高性能的HTTP和反向代理服务器
安装 brew install Nginx
Step1: 配置conf文件
Mac上默认配置文件:/usr/local/etc/nginx/nginx.conf
server {
listen 8080;
server_name localhost;
#charset utf-8;
#access_log logs/host.access.log main;
location / {
add_header Content-Type "application/json";
root html;
index index.html index.htm;
}
}
Step2: 添加测试Json文件
Mac上默认路径:/usr/local/Cellar/nginx/1.8.0/
可将文件夹,当成Http请求的路径。
如文件路径为:/usr/local/Cellar/nginx/1.8.0/html/json/user.json
则访问地址为:http://localhost:8080/json/user.json
开启nginx:sudo nginx
关闭:pkill -9 nginx
重新加载:nginx -s reload
安装 brew install Nginx
Step1: 配置conf文件
Mac上默认配置文件:/usr/local/etc/nginx/nginx.conf
server {
listen 8080;
server_name localhost;
#charset utf-8;
#access_log logs/host.access.log main;
location / {
add_header Content-Type "application/json";
root html;
index index.html index.htm;
}
}
Step2: 添加测试Json文件
Mac上默认路径:/usr/local/Cellar/nginx/1.8.0/
可将文件夹,当成Http请求的路径。
如文件路径为:/usr/local/Cellar/nginx/1.8.0/html/json/user.json
则访问地址为:http://localhost:8080/json/user.json
开启nginx:sudo nginx
关闭:pkill -9 nginx
重新加载:nginx -s reload
相关文章推荐
- memcached telnet command
- 9款经典华丽的CSS3分享按钮
- 【SSH项目实战】国税协同平台-32.我要投诉功能2
- IOS绘制文本
- leetcode Reverse Linked List---简单重点
- 神经网络为什么要有激活函数,为什么relu 能够防止梯度消失
- pt-table-checksum校验mysql数据一致性
- 对代理模式和装饰模式异同点的理解
- LeetCode-- Longest Palindromic Substring
- kafka 高吞吐量性能揭秘
- android杀掉指定包名的应用程序
- android 音频底层调试-tinyalsa
- 数据结构之创建二叉树
- Opencv——新版本2.4.2简介&FREAK和ORB特征描述子效果对比features2d
- android 从相册中获取图片设置成头像的问题:
- HTML 5怎么就成了RIA“杀手”?
- Hadoop 学习知识点总结
- 转载 :【非技术】谈谈简历那些事儿
- 【C++基础学习】Vector
- 百度2015前端研发笔试卷