nginx搭建笔记
1. nginx安装
Env: Mac OS 10.10 Yosemite
pcre: http://pcre.org/
$tar -zxf pcre-8.34.tar.gz
$cd pcre-8.34
$./configure
$make
$sudo make install
zlib: http://zlib.net/
$tar -zxf zlib-1.2..tar.gz
$cd zlib-1.2.8
$./configure
$make
$sudo make install
openssl: http://www.openssl.org/source/
$tar -zxf openssl-1.0.1j.tar.gz
$cd openssl-1.0.1j
$./config
注意下此时会有提示要编译64位版本需要用另外的指令
WARNING! If you wish to build -bit library, then you have to invoke './Configure darwin64-x86_64-cc' *manually*. You have about seconds to press Ctrl-C to abort.
$make clean
$./Configure darwin64-x86_64-cc
$make
$sudo make install
nginx: http://nginx.org/en/download.html
$tar -zxf nginx-1.7..tar.gz
$cd nginx-1.7.
$./configure --with-http_ssl_module
$make
$sudo make install
安装完毕,/usr/local/nginx为服务器安装目录
$cd /usr/local/nginx
$ls
conf html logs sbin
conf为服务器配置目录,编辑nginx.conf启用各种模块
html为网站文件目录,存放html/js/css等文件
sbin为nginx可执行文件,
$./sbin/nginx -h
nginx version: nginx/1.7.
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
启动nginx服务器: sudo /usr/local/nginx/sbin/nginx
这时候打开浏览器输入http://localhost/能显示Welcome to nginx!表示配置成功
停止、重启等操作通过-s参数,例如修改配置后重启:sudo /usr/local/nginx/sbin/nginx -s reload
2. nginx启用gzip压缩
参数设置可参考http://www.cnblogs.com/dasn/articles/4043989.html
其中gzip_types可参照nginx/conf/mime.types的映射进行设置,比apache方便不少
例如:
gzip on;
gzip_types text/plain text/html text/xml application/javascript application/json;
gzip_comp_level ;
gzip_http_version 1.0;
3. nginx缓存时间控制
expires [time|epoch|max|off]
默认off
time: 可为正负数,负数表示永远过期
epoch: 指定为1 January, 1970, 00:00:01 GMT
max: 指定为31 December 2037 23:59:59 GMT
例如:
location ~ \.(jpg|ico|png|jpeg|js|json|html|txt)$ {
expires 30d;
}
nginx搭建笔记的更多相关文章
- Nginx 笔记(四)nginx 原理与优化参数配置 与 nginx 搭建高可用集群
个人博客网:https://wushaopei.github.io/ (你想要这里多有) 一.nginx 原理与优化参数配置 master-workers 的机制的好处 首先,对于每个 ...
- 21.TFS文件系统搭建笔记
TFS文件系统搭建笔记 参考地址: https://github.com/alibaba/tfs/blob/master/INSTALL.md https://github.com/alibaba/t ...
- Nginx学习笔记~目录索引
回到占占推荐博客索引 前几天整理了<Docker的学习笔记索引>,受到了很多朋友的关注,今天把Nginx的文章也整理一下,以后将永久更新,像大叔之前的<EF文章系列>,< ...
- 转:Linux下使用Nginx搭建简单图片服务器
最近经常有人问图片上传怎么做,有哪些方案做比较好,也看到过有关于上传图片的做法,但是都不是最好的,今天再这里简单讲一下Nginx实现上传图片以及图片服务器的大致理念. 如果是个人项目或者企业小项目,仅 ...
- 用nginx搭建http/rtmp/hls协议的MP4/FLV流媒体服务器
前前后后搭建了两三个星期,终于可以告一段落,nginx实在是有点强大.写一篇笔记来记录一下这个过程中的思路和解决方案. 一.搭建nginx平台: 基本是基于http://blog.csdn.net/x ...
- nginx 搭建图片服务器(windows 下,linux 下原理应该一样)
作者的心声:很多知道的.用过的东西,不写下来,下次还要百度查询,浪费时间和精力,故本次写下学习笔记,方便下次查阅. 题外话:如有读者通过我这篇博客解决了工作上的难题,可以给个评论,让我一起分享你的喜悦 ...
- 正向代理与反向代理的区别【Nginx读书笔记】(zz)
正向代理与反向代理的区别[Nginx读书笔记] 正向代理的概念 正向代理,也就是传说中的代理,他的工作原理就像一个跳板,简单的说,我是一个用户,我访问不了某网站,但是我能访问一个代理服务器 ...
- nginx搭建http和rtmp协议的流媒体服务器
nginx搭建http和rtmp协议的流媒体服务器 时间:2013-09-23 23:52来源:佚名 作者:本站 举报 点击:232次 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtm ...
- Nginx搭建flv视频点播服务器
Nginx搭建flv视频点播服务器 前一段时间使用Nginx搭建的多媒体服务器只能在缓冲过的时间区域内拖放, 而不能拖放到未缓冲的地方. 这就带来了一个问题: 如果视频限速的速率很小, 那么客户端观看 ...
随机推荐
- prolog 内部谓词
内部谓词 和其他语言一样,prolog也提供一些基本的输入输出函数. 内部谓词是指已经在prolog中事先定义好的谓词,在内存中的动态数据库中是没有内部谓词子句的.(当我们运行某个.pl 文件的时候, ...
- bootstrap 3 with IE8 compatibility
12栅格布局在IE8下不起作用. 下载并引用html5shiv.js和respond.js 参考: 1.http://nextflow.in.th/en/keep-your-responsive-we ...
- touches, targetTouches, changedTouches 区别
1. touches: A list of information for every finger currently touching the screen2. targetTouches: Li ...
- SQL Server 表变量和临时表的区别
SQL Server 表变量和临时表的区别 一.表变量 表变量在SQL Server 2000中首次被引入.表变量的具体定义包括列定义,列名,数据类型和约束.而在表变量中可以使用的约束包括主键约束,唯 ...
- Windows服务二:测试新建的服务、调试Windows服务
一.测试Windows服务 为了使Windows服务程序能够正常运行,我们需要像创建一般应用程序那样为它创建一个程序的入口点.像其他应用程序一样,Windows服务也是在Program.cs的Main ...
- List<Object>转换为JSONArray二
package com.beijxing.TestMain; import java.util.ArrayList; import java.util.Collection; import java. ...
- android studio中如何设置注释模板
在开发程序的时候,我们一般都会给文件自动添加上一些关于文件的注释信息,比如开发者的名字,开发的时间,开发者的联系方式等等.那么在android studio中该如何设置呢? 工具/原料 andro ...
- 【补充版】HashMap(根据value筛选查找)
HashMap查找之根据Value查找 一般大家都知道对于HashMap而言都是通过key来进行查找.找到了key自然对应的value也就一并找到了.但是有些情况下就需要通过value来进行判断查找. ...
- MY SQL8.0里程碑发布
MySQL 开发团队于 12 日宣布 MySQL 8.0.0 开发里程碑版本(DMR)发布! 可能有人会惊奇 MySQL 为何从 5.x 一下跳跃到了 8.0.事实上,MySQL 5.x 系列已经延续 ...
- Markdown syntax guide and writing on MWeb
Philosophy Markdown is intended to be as easy-to-read and easy-to-write as is feasible.Readability, ...