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搭建笔记的更多相关文章

  1. Nginx 笔记(四)nginx 原理与优化参数配置 与 nginx 搭建高可用集群

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 一.nginx 原理与优化参数配置 ​ ​ master-workers 的机制的好处 首先,对于每个 ...

  2. 21.TFS文件系统搭建笔记

    TFS文件系统搭建笔记 参考地址: https://github.com/alibaba/tfs/blob/master/INSTALL.md https://github.com/alibaba/t ...

  3. Nginx学习笔记~目录索引

    回到占占推荐博客索引 前几天整理了<Docker的学习笔记索引>,受到了很多朋友的关注,今天把Nginx的文章也整理一下,以后将永久更新,像大叔之前的<EF文章系列>,< ...

  4. 转:Linux下使用Nginx搭建简单图片服务器

    最近经常有人问图片上传怎么做,有哪些方案做比较好,也看到过有关于上传图片的做法,但是都不是最好的,今天再这里简单讲一下Nginx实现上传图片以及图片服务器的大致理念. 如果是个人项目或者企业小项目,仅 ...

  5. 用nginx搭建http/rtmp/hls协议的MP4/FLV流媒体服务器

    前前后后搭建了两三个星期,终于可以告一段落,nginx实在是有点强大.写一篇笔记来记录一下这个过程中的思路和解决方案. 一.搭建nginx平台: 基本是基于http://blog.csdn.net/x ...

  6. nginx 搭建图片服务器(windows 下,linux 下原理应该一样)

    作者的心声:很多知道的.用过的东西,不写下来,下次还要百度查询,浪费时间和精力,故本次写下学习笔记,方便下次查阅. 题外话:如有读者通过我这篇博客解决了工作上的难题,可以给个评论,让我一起分享你的喜悦 ...

  7. 正向代理与反向代理的区别【Nginx读书笔记】(zz)

    正向代理与反向代理的区别[Nginx读书笔记]       正向代理的概念 正向代理,也就是传说中的代理,他的工作原理就像一个跳板,简单的说,我是一个用户,我访问不了某网站,但是我能访问一个代理服务器 ...

  8. nginx搭建http和rtmp协议的流媒体服务器

    nginx搭建http和rtmp协议的流媒体服务器 时间:2013-09-23 23:52来源:佚名 作者:本站 举报 点击:232次 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtm ...

  9. Nginx搭建flv视频点播服务器

    Nginx搭建flv视频点播服务器 前一段时间使用Nginx搭建的多媒体服务器只能在缓冲过的时间区域内拖放, 而不能拖放到未缓冲的地方. 这就带来了一个问题: 如果视频限速的速率很小, 那么客户端观看 ...

随机推荐

  1. poj3311 Hie with the Pie (状态压缩dp,旅行商)

    Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3160   Accepted: 1613 ...

  2. 《IT蓝豹》挑战独立开发项目能力

    做了5年的android开发,今天没事写写刚入行不久的时候第一次独立开发项目的心得体会,    当时我刚工作8个月,由于公司运营不善倒闭了,在2011年3月份我开始准备跳槽,    看了一周andro ...

  3. WPF开发经验

    UpdateSourceTrigger 0.在一个项目中在用到绑定的时候一直有一个问题,虽然设置了Mode=TwoWay,界面的值修改了,但是后天绑定的值没有变化.最终发现了问题,在于UpdateSo ...

  4. machine leanring 笔记 vectorization

    the summation of the product of two terms can be expressed as the product of two vectors ps.  surf   ...

  5. a标签中href的触发

    采用.trigger('click')没有效果,是用的$('xx')[0].click()来触发的.不知道为什么trigger不行,望指导.

  6. JS中this的指向问题

    JS中this的定义:this对象是在运行时基于函数的执行环境绑定的(通俗点来说就是:this代表当前函数属于哪个对象). this一般情况下都代表的是global对象,在浏览器中就是window对象 ...

  7. replaceWith() 和 replaceAll() 方法替换元素节点

    $("#Span1").replaceWith("<span title='replaceWith'>陶国荣</span>"); $(& ...

  8. bash:fdisk:command not found

    bash:fdisk:command not found [lansir@Red-Hat ~]$ fdisk -l-bash: fdisk: command not found 原因是fdisk不在P ...

  9. MAC 安装 Protobuf

    1.确认MAC装有g++.make.vim工具 2.安装make工具使用       brew install make 3.安装protobuf brew install protobuf 4.安装 ...

  10. Android消息的提示,Toast吐司方式

    1:选中某个控件进行触发 2:触发事件进行监听,然后绑定Toast对象进行消息提示 1,创建Android项目的时候,自带的一个Activity,我们看看代码 package com.example. ...